Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / migrate_plus / src / Plugin / migrate / process / SingleValue.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 single value.
11  *
12  * @code
13  * process:
14  *   field_authors:
15  *     -
16  *       plugin: explode
17  *       delimiter: ', '
18  *       source: authors
19  *     -
20  *       plugin: single_value
21  * @endcode
22  *
23  * Assume the "authors" field contains comma separated author names.
24  *
25  * After the explode, we end up with each author name as an individual value.
26  * But if we want to perform a sort on all values using a callback, we will
27  * need to send all the values to a callable together as an array of author
28  * names. Calling the "single_value" plugin in such a case will combine all the
29  * values into a single array for the next plugin.
30  *
31  * @MigrateProcessPlugin(
32  *   id = "single_value",
33  *   handle_multiples = TRUE
34  * )
35  */
36 class SingleValue extends ProcessPluginBase {
37
38   /**
39    * {@inheritdoc}
40    */
41   public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
42     return $value;
43   }
44
45 }