function EntityDeriver::getDerivativeDefinitions
Same name in this branch
- 8.9.x core/modules/rest/src/Plugin/Deriver/EntityDeriver.php \Drupal\rest\Plugin\Deriver\EntityDeriver::getDerivativeDefinitions()
Same name in other branches
- 9 core/modules/rest/src/Plugin/Deriver/EntityDeriver.php \Drupal\rest\Plugin\Deriver\EntityDeriver::getDerivativeDefinitions()
- 9 core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php \Drupal\Core\Entity\Plugin\DataType\Deriver\EntityDeriver::getDerivativeDefinitions()
- 10 core/modules/rest/src/Plugin/Deriver/EntityDeriver.php \Drupal\rest\Plugin\Deriver\EntityDeriver::getDerivativeDefinitions()
- 10 core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php \Drupal\Core\Entity\Plugin\DataType\Deriver\EntityDeriver::getDerivativeDefinitions()
- 11.x core/modules/rest/src/Plugin/Deriver/EntityDeriver.php \Drupal\rest\Plugin\Deriver\EntityDeriver::getDerivativeDefinitions()
- 11.x core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php \Drupal\Core\Entity\Plugin\DataType\Deriver\EntityDeriver::getDerivativeDefinitions()
Overrides DeriverInterface::getDerivativeDefinitions
1 call to EntityDeriver::getDerivativeDefinitions()
- EntityDeriver::getDerivativeDefinition in core/
lib/ Drupal/ Core/ Entity/ Plugin/ DataType/ Deriver/ EntityDeriver.php - Gets the definition of a derivative plugin.
File
-
core/
lib/ Drupal/ Core/ Entity/ Plugin/ DataType/ Deriver/ EntityDeriver.php, line 94
Class
- EntityDeriver
- Provides data type plugins for each existing entity type and bundle.
Namespace
Drupal\Core\Entity\Plugin\DataType\DeriverCode
public function getDerivativeDefinitions($base_plugin_definition) {
// Also keep the 'entity' defined as is.
$this->derivatives[''] = $base_plugin_definition;
// Add definitions for each entity type and bundle.
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
$class = $entity_type->entityClassImplements(ConfigEntityInterface::class) ? ConfigEntityAdapter::class : EntityAdapter::class;
$this->derivatives[$entity_type_id] = [
'class' => $class,
'label' => $entity_type->getLabel(),
'constraints' => $entity_type->getConstraints(),
'internal' => $entity_type->isInternal(),
] + $base_plugin_definition;
// Incorporate the bundles as entity:$entity_type:$bundle, if any.
$bundle_info = $this->bundleInfoService
->getBundleInfo($entity_type_id);
if (count($bundle_info) > 1 || $entity_type->getKey('bundle')) {
foreach ($bundle_info as $bundle => $info) {
$this->derivatives[$entity_type_id . ':' . $bundle] = [
'class' => $class,
'label' => $info['label'],
'constraints' => $this->derivatives[$entity_type_id]['constraints'],
] + $base_plugin_definition;
}
}
}
return $this->derivatives;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.