You are here

interface EntityEmbedDisplayInterface in Entity Embed 8

Defines the interface for Entity Embed Display plugins.

The abstraction layer provided by this plugin type may seem unnecessary at first sight. Why not just allow users of Entity Embed to choose a view mode (and its corresponding bundle-specific view display)?

There are two reasons:

  • It may be necessary to have metadata (a description for example) that is specific to a particular instance of embedding an entity. You may reference the same entity many times, but each time you want different metadata (a different description). If Entity Embed only allowed one to embed using a particular view mode, this would not be possible, since every embed would need to be rendered exactly the same.
  • Some entities can not be rendered by default because they do not have a view builder. (particularly: the File entity which is crucial for embedding of media). To still be able to embed them, an Entity Embed Display plugin can be provided.

The ability to embed an entity using a view mode/display is then just one of many Entity Embed Display plugins. It is available for all entities that can be rendered (that have a view builder).

Hierarchy

Expanded class hierarchy of EntityEmbedDisplayInterface

All classes that implement EntityEmbedDisplayInterface

See also

\Drupal\Core\Entity\Entity\EntityViewMode

\Drupal\Core\Entity\Entity\EntityViewDisplay

\Drupal\Core\Entity\EntityViewBuilderInterface

\Drupal\entity_embed\Annotation\EntityEmbedDisplay

\Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayBase

\Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager

Plugin API

1 file declares its use of EntityEmbedDisplayInterface
MediaImageDecorator.php in src/Plugin/entity_embed/EntityEmbedDisplay/MediaImageDecorator.php

File

src/EntityEmbedDisplay/EntityEmbedDisplayInterface.php, line 45

Namespace

Drupal\entity_embed\EntityEmbedDisplay
View source
interface EntityEmbedDisplayInterface extends ConfigurableInterface, DependentPluginInterface, PluginFormInterface, PluginInspectionInterface {

  /**
   * Indicates whether this Entity Embed display can be used.
   *
   * This method allows base implementations to add general access restrictions
   * that should apply to all extending Entity Embed display plugins.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   (optional) The user for which to check access, or NULL to check access
   *   for the current user. Defaults to NULL.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(AccountInterface $account = NULL);

  /**
   * Builds the renderable array for this Entity Embed display plugin.
   *
   * @return array
   *   A renderable array representing the content of the embedded entity.
   */
  public function build();

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigurableInterface::defaultConfiguration public function Gets default configuration for this plugin. 11
ConfigurableInterface::getConfiguration public function Gets this plugin's configuration. 12
ConfigurableInterface::setConfiguration public function Sets the configuration for this plugin instance. 12
DependentPluginInterface::calculateDependencies public function Calculates dependencies for the configured plugin. 19
EntityEmbedDisplayInterface::access public function Indicates whether this Entity Embed display can be used. 2
EntityEmbedDisplayInterface::build public function Builds the renderable array for this Entity Embed display plugin. 2
PluginFormInterface::buildConfigurationForm public function Form constructor. 36
PluginFormInterface::submitConfigurationForm public function Form submission handler. 32
PluginFormInterface::validateConfigurationForm public function Form validation handler. 18
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 4
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2