Interim commit.
[yaffs-website] / web / modules / contrib / entity_embed / src / EntityEmbedDisplay / EntityEmbedDisplayInterface.php
1 <?php
2
3 namespace Drupal\entity_embed\EntityEmbedDisplay;
4
5 use Drupal\Component\Plugin\PluginInspectionInterface;
6 use Drupal\Component\Plugin\ConfigurablePluginInterface;
7 use Drupal\Core\Plugin\PluginFormInterface;
8 use Drupal\Core\Session\AccountInterface;
9
10 /**
11  * Defines the interface for Entity Embed Display plugins.
12  *
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)?
16  *
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
27  *   can be provided.
28  *
29  * @see \Drupal\Core\Entity\Entity\EntityViewMode
30  * @see \Drupal\Core\Entity\Entity\EntityViewDisplay
31  * @see \Drupal\Core\Entity\EntityViewBuilderInterface
32  *
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).
36  *
37  * @see \Drupal\entity_embed\Annotation\EntityEmbedDisplay
38  * @see \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayBase
39  * @see \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager
40  * @see plugin_api
41  *
42  * @ingroup entity_embed_api
43  */
44 interface EntityEmbedDisplayInterface extends ConfigurablePluginInterface, PluginFormInterface, PluginInspectionInterface {
45
46   /**
47    * Indicates whether this Entity Embed display can be used.
48    *
49    * This method allows base implementations to add general access restrictions
50    * that should apply to all extending Entity Embed display plugins.
51    *
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.
55    *
56    * @return \Drupal\Core\Access\AccessResultInterface
57    *   The access result.
58    */
59   public function access(AccountInterface $account = NULL);
60
61   /**
62    * Builds the renderable array for this Entity Embed display plugin.
63    *
64    * @return array
65    *   A renderable array representing the content of the embedded entity.
66    */
67   public function build();
68
69 }