diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php index 9360955..ff9d49b 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php @@ -87,6 +87,13 @@ protected $pluginManager; /** + * The component handler plugin manager. + * + * @var \Drupal\entity\Plugin\Type\DisplayComponentHandlerPluginManager + */ + protected $handlerManager; + + /** * {@inheritdoc} */ public function __construct(array $values, $entity_type) { @@ -238,6 +245,29 @@ public function removeComponent($type, $name) { } /** + * Returns the component handler plugin for a given component type. + * + * @param string $type + * The component type. + * + * @return \Drupal\entity\Plugin\Type\DisplayComponentHandlerBase + * @todo interface instead + * The component handler plugin if it exists, NULL otherwise. + */ + public function getComponentHandler($type) { + $handler = $this->handlerManager->getInstance(array('type' => $type)); + if ($handler) { + $handler->setContext(array( + 'entity_type' => $this->targetEntityType, + 'bundle' => $this->bundle, + 'mode' => $this->originalMode, + 'display_context' => $this->displayContext, + )); + } + return $handler; + } + + /** * {@inheritdoc} */ public function getHighestWeight() { diff --git a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php index 39e9d22..82b39ea 100644 --- a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php +++ b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php @@ -38,13 +38,6 @@ class EntityDisplay extends EntityDisplayBase implements EntityDisplayInterface protected $renderers = array(); /** - * The component handler plugin manager. - * - * @var \Drupal\entity\Plugin\Type\DisplayComponentHandlerPluginManager - */ - protected $handlersManager; - - /** * {@inheritdoc} */ public function __construct(array $values, $entity_type) { @@ -52,12 +45,12 @@ public function __construct(array $values, $entity_type) { $this->displayContext = 'display'; // Get the 'component handler' plugin manager. - $this->handlersManager = drupal_container()->get('plugin.manager.entity.display_component_handler'); + $this->handlerManager = drupal_container()->get('plugin.manager.entity.display_component_handler'); parent::__construct($values, $entity_type); // Let the component handlers add missing components. - $handlers = $this->handlersManager->getDefinitions(); + $handlers = $this->handlerManager->getDefinitions(); foreach (array_keys($handlers) as $type) { $this->getComponentHandler($type)->prepareDisplayComponents($this->content); } @@ -65,29 +58,6 @@ public function __construct(array $values, $entity_type) { } /** - * Returns the component handler plugin for a given component type. - * - * @param string $type - * The component type. - * - * @return \Drupal\entity\Plugin\Type\DisplayComponentHandlerBase - * @todo interface instead - * The component handler plugin if it exists, NULL otherwise. - */ - public function getComponentHandler($type) { - $handler = $this->handlersManager->getInstance(array('type' => $type)); - if ($handler) { - $handler->setContext(array( - 'entity_type' => $this->targetEntityType, - 'bundle' => $this->bundle, - 'view_mode' => $this->originalMode, - 'display_context' => $this->displayContext, - )); - } - return $handler; - } - - /** * {@inheritdoc} */ public function getRenderer($type, $name) { diff --git a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityFormDisplay.php b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityFormDisplay.php index 3cea363..d255cc2 100644 --- a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityFormDisplay.php +++ b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityFormDisplay.php @@ -33,13 +33,6 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayInterface, \Serializable { /** - * The component handler plugin manager. - * - * @var \Drupal\entity\Plugin\Type\DisplayComponentHandlerPluginManager - */ - protected $handlersManager; - - /** * {@inheritdoc} */ public function __construct(array $values, $entity_type) { @@ -47,12 +40,12 @@ public function __construct(array $values, $entity_type) { $this->displayContext = 'form'; // Get the 'component handler' plugin manager. - $this->handlersManager = drupal_container()->get('plugin.manager.entity.display_component_handler'); + $this->handlerManager = drupal_container()->get('plugin.manager.entity.display_component_handler'); parent::__construct($values, $entity_type); // Let the component handlers add missing components. - $handlers = $this->handlersManager->getDefinitions(); + $handlers = $this->handlerManager->getDefinitions(); foreach (array_keys($handlers) as $type) { $this->getComponentHandler($type)->prepareDisplayComponents($this->content); } @@ -62,23 +55,6 @@ public function __construct(array $values, $entity_type) { /** * {@inheritdoc} */ - public function getComponentHandler($type) { - // @todo this should move to displayBase. - $handler = $this->handlersManager->getInstance(array('type' => $type)); - if ($handler) { - $handler->setContext(array( - 'entity_type' => $this->targetEntityType, - 'bundle' => $this->bundle, - 'view_mode' => $this->originalMode, - 'display_context' => $this->displayContext, - )); - } - return $handler; - } - - /** - * {@inheritdoc} - */ public function getRenderer($type, $field_name) { if (isset($this->plugins[$field_name])) { return $this->plugins[$field_name];