summaryrefslogtreecommitdiffstats
path: root/core/lib/Drupal/Core/Entity/EntityManager.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/lib/Drupal/Core/Entity/EntityManager.php')
-rw-r--r--core/lib/Drupal/Core/Entity/EntityManager.php33
1 files changed, 20 insertions, 13 deletions
diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php
index 128d21d..7d7eded 100644
--- a/core/lib/Drupal/Core/Entity/EntityManager.php
+++ b/core/lib/Drupal/Core/Entity/EntityManager.php
@@ -324,19 +324,7 @@ class EntityManager extends DefaultPluginManager implements EntityManagerInterfa
if (!$class) {
throw new InvalidPluginDefinitionException($entity_type, sprintf('The "%s" entity type did not specify a %s handler.', $entity_type, $handler_type));
}
- if (is_subclass_of($class, 'Drupal\Core\Entity\EntityHandlerInterface')) {
- $handler = $class::createInstance($this->container, $definition);
- }
- else {
- $handler = new $class($definition);
- }
- if (method_exists($handler, 'setModuleHandler')) {
- $handler->setModuleHandler($this->moduleHandler);
- }
- if (method_exists($handler, 'setStringTranslation')) {
- $handler->setStringTranslation($this->translationManager);
- }
- $this->handlers[$handler_type][$entity_type] = $handler;
+ $this->handlers[$handler_type][$entity_type] = $this->createHandlerInstance($class, $definition);
}
return $this->handlers[$handler_type][$entity_type];
}
@@ -344,6 +332,25 @@ class EntityManager extends DefaultPluginManager implements EntityManagerInterfa
/**
* {@inheritdoc}
*/
+ public function createHandlerInstance($class, EntityTypeInterface $definition = null) {
+ if (is_subclass_of($class, 'Drupal\Core\Entity\EntityHandlerInterface')) {
+ $handler = $class::createInstance($this->container, $definition);
+ }
+ else {
+ $handler = new $class($definition);
+ }
+ if (method_exists($handler, 'setModuleHandler')) {
+ $handler->setModuleHandler($this->moduleHandler);
+ }
+ if (method_exists($handler, 'setStringTranslation')) {
+ $handler->setStringTranslation($this->translationManager);
+ }
+ return $handler;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function getBaseFieldDefinitions($entity_type_id) {
// Check the static cache.
if (!isset($this->baseFieldDefinitions[$entity_type_id])) {