class Get
Gets the source value.
Available configuration keys:
- source: Source property.
The get plugin returns the value of the property given by the "source" configuration key.
Examples:
process:
bar:
plugin: get
source: foo
This copies the source value of foo to the destination property "bar".
Since get is the default process plugin, it can be shorthanded like this:
process:
bar:
foo;
Get also supports a list of source properties.
Example:
process:
bar:
plugin: get
source:
- foo1
- foo2
This copies the array of source values [foo1, foo2] to the destination property "bar".
If the list of source properties contains an empty element then the current value will be used. This makes it impossible to reach a source property with an empty string as its name.
Get also supports copying destination values. These are indicated by a starting @ sign. Values using @ must be wrapped in quotes.
process:
foo:
plugin: machine_name
source: baz
bar:
plugin: get
source: '@foo'
This will simply copy the destination value of foo to the destination property bar. foo configuration is included for illustration purposes.
Because of this, if the source or destination property actually starts with a "@", that character must be escaped with "@@". The referenced property becomes, for example, "@@@foo".
process:
'@foo':
plugin: machine_name
source: baz
bar:
plugin: get
source: '@@@foo'
This should occur extremely rarely.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
- class \Drupal\migrate\ProcessPluginBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\migrate\Plugin\MigrateProcessInterface
- class \Drupal\migrate\Plugin\migrate\process\Get extends \Drupal\migrate\ProcessPluginBase
- class \Drupal\migrate\ProcessPluginBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\migrate\Plugin\MigrateProcessInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
Expanded class hierarchy of Get
See also
\Drupal\migrate\Plugin\MigrateProcessInterface
141 string references to 'Get'
- AbstractBrowser::followRedirect in vendor/
symfony/ browser-kit/ AbstractBrowser.php - Follow redirects?
- AbstractStorage::get in vendor/
lullabot/ php-webdriver/ lib/ WebDriver/ Storage/ AbstractStorage.php - Get all keys from storage or a specific key/value pair
- AbstractStorage::methods in vendor/
lullabot/ php-webdriver/ lib/ WebDriver/ Storage/ AbstractStorage.php - Return array of supported method names and corresponding HTTP request methods
- AbstractUriElement::getMethod in vendor/
symfony/ dom-crawler/ AbstractUriElement.php - Gets the method associated with this link.
- Alert::methods in vendor/
lullabot/ php-webdriver/ lib/ WebDriver/ Alert.php - Return array of supported method names and corresponding HTTP request methods
File
-
core/
modules/ migrate/ src/ Plugin/ migrate/ process/ Get.php, line 91
Namespace
Drupal\migrate\Plugin\migrate\processView source
class Get extends ProcessPluginBase {
/**
* Flag indicating whether there are multiple values.
*
* @var bool
*/
protected $multiple;
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$source = $this->configuration['source'];
$properties = is_string($source) ? [
$source,
] : $source;
$return = [];
foreach ($properties as $property) {
if ($property || (string) $property === '0') {
$return[] = $row->get($property);
}
else {
$return[] = $value;
}
}
if (is_string($source)) {
$this->multiple = is_array($return[0]);
return $return[0];
}
return $return;
}
/**
* {@inheritdoc}
*/
public function multiple() {
return $this->multiple;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
Get::$multiple | protected | property | Flag indicating whether there are multiple values. | ||
Get::multiple | public | function | Indicates whether the returned value requires multiple handling. | Overrides ProcessPluginBase::multiple | |
Get::transform | public | function | Performs the associated process. | Overrides ProcessPluginBase::transform | |
PluginInspectionInterface::getPluginDefinition | public | function | Gets the definition of the plugin implementation. | 5 | |
PluginInspectionInterface::getPluginId | public | function | Gets the plugin ID of the plugin instance. | 2 | |
ProcessPluginBase::$stopPipeline | protected | property | Determines if processing of the pipeline is stopped. | ||
ProcessPluginBase::isPipelineStopped | public | function | Determines if the pipeline should stop processing. | Overrides MigrateProcessInterface::isPipelineStopped | |
ProcessPluginBase::reset | public | function | Resets the internal data of a plugin. | Overrides MigrateProcessInterface::reset | |
ProcessPluginBase::stopPipeline | protected | function | Stops pipeline processing after this plugin finishes. |