Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / migrate_plus / src / Plugin / migrate / process / MultipleValues.php
1 <?php
2
3 namespace Drupal\migrate_plus\Plugin\migrate\process;
4
5 use Drupal\migrate\MigrateExecutableInterface;
6 use Drupal\migrate\ProcessPluginBase;
7 use Drupal\migrate\Row;
8
9 /**
10  * Treat an array of values as a separate / individual values.
11  *
12  * @code
13  * process:
14  *   field_authors:
15  *     -
16  *       plugin: explode
17  *       delimiter: ', '
18  *       source: authors
19  *     -
20  *       plugin: single_value
21  *     -
22  *       plugin: callback
23  *       callable: custom_sort_authors
24  *     -
25  *       plugin: multiple_values
26  * @endcode
27  *
28  * Assume the "authors" field contains comma separated author names.
29  *
30  * We split the names into multiple values and then use the "single_value"
31  * plugin to treat them as a single array of author names. After that, we
32  * pass the values through a custom sort. Callback multiple setting is false. To
33  * convert from a single value to multiple, use the "multiple_values" plugin. It
34  * will make the next plugin treat the values individually instead of an array
35  * of values.
36  *
37  * @MigrateProcessPlugin(
38  *   id = "multiple_values",
39  *   handle_multiples = TRUE
40  * )
41  */
42 class MultipleValues extends ProcessPluginBase {
43
44   /**
45    * {@inheritdoc}
46    */
47   public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
48     return $value;
49   }
50
51   /**
52    * {@inheritdoc}
53    */
54   public function multiple() {
55     return TRUE;
56   }
57
58 }