diff --git a/src/Annotation/EntityEmbedDisplay.php b/src/Annotation/EntityEmbedDisplay.php index 03fa2fd9..2d66cea1 100644 --- a/src/Annotation/EntityEmbedDisplay.php +++ b/src/Annotation/EntityEmbedDisplay.php @@ -32,7 +32,16 @@ class EntityEmbedDisplay extends Plugin { * * @var \Drupal\Core\Annotation\Translation */ - public $label = ''; + public $label; + + /** + * A short description of the display plugin. + * + * @ingroup plugin_translatable + * + * @var \Drupal\Core\Annotation\Translation + */ + public $description; /** * The entity types the display can apply to. diff --git a/src/Plugin/Derivative/FieldFormatterDeriver.php b/src/Plugin/Derivative/FieldFormatterDeriver.php index 350c50cf..605301f1 100644 --- a/src/Plugin/Derivative/FieldFormatterDeriver.php +++ b/src/Plugin/Derivative/FieldFormatterDeriver.php @@ -57,9 +57,13 @@ public function getDerivativeDefinitions($base_plugin_definition) { if (!isset($base_plugin_definition['field_type'])) { throw new \LogicException("Undefined field_type definition in plugin {$base_plugin_definition['id']}."); } + $plugin_definitions = $this->formatterManager->getDefinitions(); foreach ($this->formatterManager->getOptions($base_plugin_definition['field_type']) as $formatter => $label) { $this->derivatives[$formatter] = $base_plugin_definition; $this->derivatives[$formatter]['label'] = $label; + if (isset($plugin_definitions[$formatter]['description'])) { + $this->derivatives[$formatter]['description'] = $plugin_definitions[$formatter]['description']; + } } return $this->derivatives; } diff --git a/src/Plugin/EmbedType/Entity.php b/src/Plugin/EmbedType/Entity.php index ee19402e..9ad0abb2 100644 --- a/src/Plugin/EmbedType/Entity.php +++ b/src/Plugin/EmbedType/Entity.php @@ -118,6 +118,12 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#description' => $this->t('If none are selected, all are allowed. Note that these are the plugins which are allowed for this entity type, all of these might not be available for the selected entity.'), ); $form['display_plugins']['#access'] = !empty($form['display_plugins']['#options']); + $display_plugins = $this->displayPluginManager->getDefinitions(); + foreach (array_keys($form['display_plugins']['#options']) as $plugin_id) { + if (!empty($display_plugins[$plugin_id]['description'])) { + $form['display_plugins'][$plugin_id]['#description'] = $display_plugins[$plugin_id]['description']; + } + } } return $form;