class Callback
Same name in other branches
- 9 core/modules/migrate/src/Plugin/migrate/process/Callback.php \Drupal\migrate\Plugin\migrate\process\Callback
- 10 core/modules/migrate/src/Plugin/migrate/process/Callback.php \Drupal\migrate\Plugin\migrate\process\Callback
- 11.x core/modules/migrate/src/Plugin/migrate/process/Callback.php \Drupal\migrate\Plugin\migrate\process\Callback
Passes the source value to a callback.
The callback process plugin allows simple processing of the value, such as strtolower(). The callable takes the source value as the single mandatory argument. No additional arguments can be passed to the callback.
Available configuration keys:
- callable: The name of the callable method.
Examples:
process:
destination_field:
plugin: callback
callable: strtolower
source: source_field
An example where the callable is a static method in a class:
process:
destination_field:
plugin: callback
callable:
- '\Drupal\Component\Utility\Unicode'
- strtolower
source: source_field
Plugin annotation
@MigrateProcessPlugin(
id = "callback"
)
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\Callback 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 Callback
See also
\Drupal\migrate\Plugin\MigrateProcessInterface
1 file declares its use of Callback
- CallbackTest.php in core/
modules/ migrate/ tests/ src/ Unit/ process/ CallbackTest.php
21 string references to 'Callback'
- BubbleableMetadataTest::providerTestMerge in core/
tests/ Drupal/ Tests/ Core/ Render/ BubbleableMetadataTest.php - Provides test data for testMerge().
- ConstraintManager::registerDefinitions in core/
lib/ Drupal/ Core/ Validation/ ConstraintManager.php - Callback for registering definitions for constraints shipped with Symfony.
- d6_action.yml in core/
modules/ action/ migrations/ d6_action.yml - core/modules/action/migrations/d6_action.yml
- d6_custom_block_translation.yml in core/
modules/ content_translation/ migrations/ d6_custom_block_translation.yml - core/modules/content_translation/migrations/d6_custom_block_translation.yml
- d6_menu_links_translation.yml in core/
modules/ content_translation/ migrations/ d6_menu_links_translation.yml - core/modules/content_translation/migrations/d6_menu_links_translation.yml
File
-
core/
modules/ migrate/ src/ Plugin/ migrate/ process/ Callback.php, line 47
Namespace
Drupal\migrate\Plugin\migrate\processView source
class Callback extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
if (!isset($configuration['callable'])) {
throw new \InvalidArgumentException('The "callable" must be set.');
}
elseif (!is_callable($configuration['callable'])) {
throw new \InvalidArgumentException('The "callable" must be a valid function or method.');
}
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
return call_user_func($this->configuration['callable'], $value);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
Callback::transform | public | function | Performs the associated process. | Overrides ProcessPluginBase::transform | |
Callback::__construct | public | function | |||
PluginInspectionInterface::getPluginDefinition | public | function | Gets the definition of the plugin implementation. | 6 | |
PluginInspectionInterface::getPluginId | public | function | Gets the plugin_id of the plugin instance. | 2 | |
ProcessPluginBase::multiple | public | function | Indicates whether the returned value requires multiple handling. | Overrides MigrateProcessInterface::multiple | 3 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.