function EntityTypeManager::findDefinitions
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Entity/EntityTypeManager.php \Drupal\Core\Entity\EntityTypeManager::findDefinitions()
- 10 core/lib/Drupal/Core/Entity/EntityTypeManager.php \Drupal\Core\Entity\EntityTypeManager::findDefinitions()
- 9 core/lib/Drupal/Core/Entity/EntityTypeManager.php \Drupal\Core\Entity\EntityTypeManager::findDefinitions()
- 8.9.x core/lib/Drupal/Core/Entity/EntityTypeManager.php \Drupal\Core\Entity\EntityTypeManager::findDefinitions()
Finds plugin definitions.
Return value
array List of definitions to store in cache.
Overrides DefaultPluginManager::findDefinitions
File
-
core/
lib/ Drupal/ Core/ Entity/ EntityTypeManager.php, line 116
Class
- EntityTypeManager
- Manages entity type plugin definitions.
Namespace
Drupal\Core\EntityCode
protected function findDefinitions() {
$definitions = $this->getDiscovery()
->getDefinitions();
$bundle_class_bundle_info = [];
$definitions = array_filter($definitions, function (EntityTypeInterface $definition, string $id) use (&$bundle_class_bundle_info) {
// Derivatives are bundle class definitions and not actual entity types.
if (str_contains($id, PluginBase::DERIVATIVE_SEPARATOR)) {
$bundle_info = $definition->get('entity_type_bundle_info');
if ($bundle_info !== NULL) {
// Normalize the class string.
$this->processDefinition($definition, $id);
[$entity_type_id, $bundle] = explode(PluginBase::DERIVATIVE_SEPARATOR, $id);
$bundle_class_bundle_info[$entity_type_id][$bundle] = [
'class' => $definition->getClass(),
'label' => $definition->getLabel(),
'translatable' => $bundle_info[$bundle]['translatable'],
];
}
return FALSE;
}
return TRUE;
}, ARRAY_FILTER_USE_BOTH);
$this->moduleHandler
->invokeAllWith('entity_type_build', function (callable $hook, string $module) use (&$definitions) {
$hook($definitions);
});
foreach ($definitions as $plugin_id => $definition) {
$this->processDefinition($definition, $plugin_id);
}
foreach ($bundle_class_bundle_info as $entity_type_id => $bundle_data) {
if (!isset($definitions[$entity_type_id])) {
continue;
}
$entity_type_bundle_info = $definitions[$entity_type_id]->get('entity_type_bundle_info') ?? [];
$entity_type_bundle_info += $bundle_data;
$definitions[$entity_type_id]->set('entity_type_bundle_info', $entity_type_bundle_info);
}
$this->alterDefinitions($definitions);
return $definitions;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.