3 namespace Drupal\entity_embed\EntityEmbedDisplay;
5 use Drupal\Component\Plugin\PluginInspectionInterface;
6 use Drupal\Component\Plugin\ConfigurablePluginInterface;
7 use Drupal\Core\Plugin\PluginFormInterface;
8 use Drupal\Core\Session\AccountInterface;
11 * Defines the interface for Entity Embed Display plugins.
13 * The abstraction layer provided by this plugin type may seem unnecessary at
14 * first sight. Why not just allow users of Entity Embed to choose a view mode
15 * (and its corresponding bundle-specific view display)?
17 * There are two reasons:
18 * - It may be necessary to have metadata (a description for example) that is
19 * specific to a particular instance of embedding an entity. You may reference
20 * the same entity many times, but each time you want different metadata (a
21 * different description). If Entity Embed only allowed one to embed using a
22 * particular view mode, this would not be possible, since every embed would
23 * need to be rendered exactly the same.
24 * - Some entities can not be rendered by default because they do not have a
25 * view builder. (particularly: the File entity which is crucial for embedding
26 * of media). To still be able to embed them, an Entity Embed Display plugin
29 * @see \Drupal\Core\Entity\Entity\EntityViewMode
30 * @see \Drupal\Core\Entity\Entity\EntityViewDisplay
31 * @see \Drupal\Core\Entity\EntityViewBuilderInterface
33 * The ability to embed an entity using a view mode/display is then just one of
34 * many Entity Embed Display plugins. It is available for all entities that can
35 * be rendered (that have a view builder).
37 * @see \Drupal\entity_embed\Annotation\EntityEmbedDisplay
38 * @see \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayBase
39 * @see \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager
42 * @ingroup entity_embed_api
44 interface EntityEmbedDisplayInterface extends ConfigurablePluginInterface, PluginFormInterface, PluginInspectionInterface {
47 * Indicates whether this Entity Embed display can be used.
49 * This method allows base implementations to add general access restrictions
50 * that should apply to all extending Entity Embed display plugins.
52 * @param \Drupal\Core\Session\AccountInterface $account
53 * (optional) The user for which to check access, or NULL to check access
54 * for the current user. Defaults to NULL.
56 * @return \Drupal\Core\Access\AccessResultInterface
59 public function access(AccountInterface $account = NULL);
62 * Builds the renderable array for this Entity Embed display plugin.
65 * A renderable array representing the content of the embedded entity.
67 public function build();