public function DynamicAddEntityLocalActions::getDerivativeDefinitions in Apigee Edge 8
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/ Derivative/ DynamicAddEntityLocalActions.php, line 89
Class
- DynamicAddEntityLocalActions
- Add add entity local actions for Apigee Edge entity's collection routes.
Namespace
Drupal\apigee_edge\Plugin\DerivativeCode
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = [];
foreach ($this->entityTypeManager
->getDefinitions() as $type) {
if ($type instanceof EdgeEntityTypeInterface) {
foreach ($this->entityTypeManager
->getRouteProviders($type
->id()) as $provider) {
$collection_route_name = "entity.{$type->id()}.collection";
$collection_route = $provider
->getRoutes($type)
->get($collection_route_name);
$add_form_route_name = "entity.{$type->id()}.add_form";
$add_form_route = $provider
->getRoutes($type)
->get($add_form_route_name);
if ($collection_route && $add_form_route) {
$this->derivatives["{$type->getProvider()}.{$type->id()}.add_form"] = [
'route_name' => $add_form_route_name,
'title' => $this
->t('Add @entity-type', [
'@entity-type' => mb_strtolower($type
->getSingularLabel()),
]),
'appears_on' => [
$collection_route_name,
],
] + $base_plugin_definition;
break;
}
}
}
}
return $this->derivatives;
}