Skip to content
This repository was archived by the owner on Jan 5, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Annotation/EntityEmbedDisplay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions src/Plugin/Derivative/FieldFormatterDeriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions src/Plugin/EmbedType/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down