diff --git a/core/modules/entity/lib/Drupal/entity/Plugin/Type/DisplayComponentHandlerBase.php b/core/modules/entity/lib/Drupal/entity/DisplayComponentHandlerBase.php similarity index 41% rename from core/modules/entity/lib/Drupal/entity/Plugin/Type/DisplayComponentHandlerBase.php rename to core/modules/entity/lib/Drupal/entity/DisplayComponentHandlerBase.php index ce1a88b..3586976 100644 --- a/core/modules/entity/lib/Drupal/entity/Plugin/Type/DisplayComponentHandlerBase.php +++ b/core/modules/entity/lib/Drupal/entity/DisplayComponentHandlerBase.php @@ -2,17 +2,17 @@ /** * @file - * Contains \Drupal\entity\Plugin\Type\DisplayComponentHandlerBase. + * Contains \Drupal\entity\DisplayComponentHandlerBase. */ -namespace Drupal\entity\Plugin\Type; +namespace Drupal\entity; use Drupal\Component\Plugin\PluginBase; /** - * Provides a base class for DisplayComponent plugins. + * Provides a base class for DisplayComponentHandler plugins. */ -abstract class DisplayComponentHandlerBase extends PluginBase { +abstract class DisplayComponentHandlerBase extends PluginBase implements DisplayComponentHandlerInterface { /** * The context in which the handler is being used. @@ -22,43 +22,29 @@ protected $context; /** - * Sets the context for the rendering component. - * - * @param array $context + * {@inheritdoc} */ public function setContext(array $context) { $this->context = $context; } /** - * @todo - * - * @param array $components + * {@inheritdoc} */ public function prepareDisplayComponents(array &$components, array &$hidden_components) { } /** - * Checks if the component handler has the passed element - * - * @param array $name - * The name of the element + * {@inheritdoc} */ public function hasElement($name) { return FALSE; } /** - * @todo - * - * @param $name - * The name of the element - * @params $options - * The options for this element. - * - * @return array + * {@inheritdoc} */ - public function massageIn($name, array $options = null) { + public function massageIn($name, array $options) { return $options; } @@ -70,14 +56,9 @@ public function massageOut($properties) { } /** - * Returns the render for this display. - * - * @param $name - * The name of the element - * @params $options - * The options for this element. + * {@inheritdoc} */ - public function getRenderer($name, $options = null) { + public function getRenderer($name, array $options) { } } diff --git a/core/modules/entity/lib/Drupal/entity/DisplayComponentHandlerInterface.php b/core/modules/entity/lib/Drupal/entity/DisplayComponentHandlerInterface.php new file mode 100644 index 0000000..a13a184 --- /dev/null +++ b/core/modules/entity/lib/Drupal/entity/DisplayComponentHandlerInterface.php @@ -0,0 +1,88 @@ +handlers[$name])) { @@ -303,13 +303,14 @@ public function getComponentHandlerByElementName($name) { return $this->handlers[$name]; } + /** * Instantiates component handler. * * @param string $type * The type of component handler (field, extra_field). * - * @return \Drupal\entity\Plugin\Type\DisplayComponentHandlerBase + * @return \Drupal\entity\DisplayComponentHandlerInterface */ public function getComponentHandler($type) { $handler = $this->handlerManager->getInstance(array('type' => $type)); @@ -333,8 +334,8 @@ public function getRenderer($name) { } if (!array_key_exists($name, $this->renderers)) { - $options = $this->getComponent($name); if ($handler = $this->getComponentHandlerByElementName($name)) { + $options = $this->getComponent($name); $this->renderers[$name] = $handler->getRenderer($name, $options); } else { diff --git a/core/modules/entity/lib/Drupal/entity/Plugin/DisplayComponent/ExtraFieldDisplayComponentHandler.php b/core/modules/entity/lib/Drupal/entity/Plugin/DisplayComponent/ExtraFieldDisplayComponentHandler.php index 799c6cb..3363071 100644 --- a/core/modules/entity/lib/Drupal/entity/Plugin/DisplayComponent/ExtraFieldDisplayComponentHandler.php +++ b/core/modules/entity/lib/Drupal/entity/Plugin/DisplayComponent/ExtraFieldDisplayComponentHandler.php @@ -7,7 +7,7 @@ namespace Drupal\entity\Plugin\DisplayComponent; -use Drupal\entity\Plugin\Type\DisplayComponentHandlerBase; +use Drupal\entity\DisplayComponentHandlerBase; /** * Provides a component handler to manage entity extra fields. diff --git a/core/modules/field/lib/Drupal/field/Plugin/DisplayComponent/FieldDisplayComponentHandler.php b/core/modules/field/lib/Drupal/field/Plugin/DisplayComponent/FieldDisplayComponentHandler.php index 65cf61f..b56f459 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/DisplayComponent/FieldDisplayComponentHandler.php +++ b/core/modules/field/lib/Drupal/field/Plugin/DisplayComponent/FieldDisplayComponentHandler.php @@ -11,7 +11,7 @@ use Drupal\Core\Field\FormatterPluginManager; use Drupal\Core\Field\WidgetPluginManager; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\entity\Plugin\Type\DisplayComponentHandlerBase; +use Drupal\entity\DisplayComponentHandlerBase; use Drupal\field\FieldInfo; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -90,7 +90,7 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritdoc} */ - public function massageIn($name, array $options = array()) { + public function massageIn($name, array $options) { $field_definition = $this->getFieldDefinition($name); if (!isset($field_definition)) { // The field in process of removal from display. @@ -153,7 +153,7 @@ public function prepareDisplayComponents(array &$components, array &$hidden_comp /** * {@inheritdoc} */ - public function getRenderer($name, $options = NULL) { + public function getRenderer($name, array $options) { if (isset($options['type']) && ($definition = $this->getFieldDefinition($name))) { if ($this->context['display_context'] == 'view') { $plugin_manager = $this->formatterPluginManager; @@ -173,9 +173,7 @@ public function getRenderer($name, $options = NULL) { 'configuration' => $options, )); } - else { - return NULL; - } + return NULL; } /**