You are here

class Iterator in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate/src/Plugin/migrate/process/Iterator.php \Drupal\migrate\Plugin\migrate\process\Iterator

This plugin iterates and processes an array.

Plugin annotation


@MigrateProcessPlugin(
  id = "iterator",
  handle_multiples = TRUE
)

Hierarchy

Expanded class hierarchy of Iterator

See also

https://www.drupal.org/node/2135345

1 file declares its use of Iterator
IteratorTest.php in core/modules/migrate/tests/src/Unit/process/IteratorTest.php
Contains \Drupal\Tests\migrate\Unit\process\IteratorTest.
7 string references to 'Iterator'
DoublerSpec::its_double_mirrors_alterates_and_instantiates_provided_class in vendor/phpspec/prophecy/spec/Prophecy/Doubler/DoublerSpec.php
Framework_MockObjectTest::traversableProvider in vendor/phpunit/phpunit-mock-objects/tests/MockObjectTest.php
PHPUnit_Framework_MockObject_Generator::generateMock in vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator.php
PHPUnit_Framework_MockObject_Generator::getMock in vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/Generator.php
Returns a mock object for the specified class.
TraversablePatch::apply in vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/TraversablePatch.php
Forces class to implement Iterator interface.

... See full list

File

core/modules/migrate/src/Plugin/migrate/process/Iterator.php, line 24
Contains \Drupal\migrate\Plugin\migrate\process\Iterator.

Namespace

Drupal\migrate\Plugin\migrate\process
View source
class Iterator extends ProcessPluginBase {

  /**
   * Runs a process pipeline on each destination property per list item.
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    $return = array();
    foreach ($value as $key => $new_value) {
      $new_row = new Row($new_value, array());
      $migrate_executable
        ->processRow($new_row, $this->configuration['process']);
      $destination = $new_row
        ->getDestination();
      if (array_key_exists('key', $this->configuration)) {
        $key = $this
          ->transformKey($key, $migrate_executable, $new_row);
      }
      $return[$key] = $destination;
    }
    return $return;
  }

  /**
   * Runs the process pipeline for the current key.
   *
   * @param string|int $key
   *   The current key.
   * @param \Drupal\migrate\MigrateExecutableInterface $migrate_executable
   *   The migrate executable helper class.
   * @param \Drupal\migrate\Row $row
   *   The current row after processing.
   *
   * @return mixed
   *   The transformed key.
   */
  protected function transformKey($key, MigrateExecutableInterface $migrate_executable, Row $row) {
    $process = array(
      'key' => $this->configuration['key'],
    );
    $migrate_executable
      ->processRow($row, $process, $key);
    return $row
      ->getDestinationProperty('key');
  }

  /**
   * {@inheritdoc}
   */
  public function multiple() {
    return TRUE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
Iterator::multiple public function Indicates whether the returned value requires multiple handling. Overrides ProcessPluginBase::multiple
Iterator::transform public function Runs a process pipeline on each destination property per list item. Overrides ProcessPluginBase::transform
Iterator::transformKey protected function Runs the process pipeline for the current key.
PluginBase::$configuration protected property Configuration information passed into the plugin. 2
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::__construct public function Constructs a Drupal\Component\Plugin\PluginBase object. 69
StringTranslationTrait::$stringTranslation protected property The string translation service.
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.