3 namespace Drupal\migrate_plus\Plugin\migrate\process;
5 use Drupal\migrate\MigrateException;
6 use Drupal\migrate\MigrateExecutableInterface;
7 use Drupal\migrate\ProcessPluginBase;
8 use Drupal\migrate\Row;
11 * Performs an array_shift() on a source array.
13 * @MigrateProcessPlugin(
15 * handle_multiples = TRUE
18 * The "extract" plugin in core can extract array values when indexes are
19 * already known. This plugin helps extract the first value in an array by
20 * performing a "shift" operation.
22 * Example: Say, the migration source has an associative array of names in
23 * a property called "authors" and the keys in the array can vary, you
24 * can extract the first value like this:
32 class ArrayShift extends ProcessPluginBase {
37 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
38 if (!is_array($value)) {
39 throw new MigrateException('Input should be an array.');
41 return array_shift($value);