public function PluginItemDeriver::getDerivativeDefinitions in Commerce Core 8.2
Gets the definition of all derivatives of a base plugin.
Parameters
array $base_plugin_definition: The definition array of the base plugin.
Return value
array An array of full derivative definitions keyed on derivative id.
Overrides DeriverBase::getDerivativeDefinitions
See also
getDerivativeDefinition()
File
- src/
Plugin/ Field/ FieldType/ PluginItemDeriver.php, line 53
Class
- PluginItemDeriver
- Deriver for the commerce_plugin_item field type.
Namespace
Drupal\commerce\Plugin\Field\FieldTypeCode
public function getDerivativeDefinitions($base_plugin_definition) {
$plugin_types = [
'commerce_condition' => $this
->t('Condition'),
'commerce_promotion_offer' => $this
->t('Promotion offer'),
];
// Core has no way to list plugin types, so each referenceable plugin
// type needs to register itself via the event.
$event = new ReferenceablePluginTypesEvent($plugin_types);
$this->eventDispatcher
->dispatch(CommerceEvents::REFERENCEABLE_PLUGIN_TYPES, $event);
$plugin_types = $event
->getPluginTypes();
foreach ($plugin_types as $plugin_type => $label) {
$this->derivatives[$plugin_type] = [
'plugin_type' => $plugin_type,
'label' => $label,
'category' => $this
->t('Plugin'),
] + $base_plugin_definition;
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}