Get.php in Zircon Profile 8.0
File
core/modules/migrate/src/Plugin/migrate/process/Get.php
View source
<?php
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
class Get extends ProcessPluginBase {
protected $multiple;
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$source = $this->configuration['source'];
$properties = is_string($source) ? array(
$source,
) : $source;
$return = array();
foreach ($properties as $property) {
if (empty($property)) {
$return[] = $value;
}
else {
$is_source = TRUE;
if ($property[0] == '@') {
$property = preg_replace_callback('/^(@?)((?:@@)*)([^@]|$)/', function ($matches) use (&$is_source) {
$is_source = empty($matches[1]);
return str_replace('@@', '@', $matches[2]) . $matches[3];
}, $property);
}
if ($is_source) {
$return[] = $row
->getSourceProperty($property);
}
else {
$return[] = $row
->getDestinationProperty($property);
}
}
}
if (is_string($source)) {
$this->multiple = is_array($return[0]);
return $return[0];
}
return $return;
}
public function multiple() {
return $this->multiple;
}
}
Classes
Name |
Description |
Get |
This plugin copies from the source to the destination. |