0ccac97050bd5e29ba16d31844b27c87fe8ad8cb
[yaffs-website] / web / core / lib / Drupal / Core / Entity / EntityTypeManagerInterface.php
1 <?php
2
3 namespace Drupal\Core\Entity;
4
5 use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
6 use Drupal\Component\Plugin\PluginManagerInterface;
7
8 /**
9  * Provides an interface for entity type managers.
10  */
11 interface EntityTypeManagerInterface extends PluginManagerInterface, CachedDiscoveryInterface {
12
13   /**
14    * Creates a new access control handler instance.
15    *
16    * @param string $entity_type
17    *   The entity type for this access control handler.
18    *
19    * @return \Drupal\Core\Entity\EntityAccessControlHandlerInterface
20    *   A access control handler instance.
21    */
22   public function getAccessControlHandler($entity_type);
23
24   /**
25    * Creates a new storage instance.
26    *
27    * @param string $entity_type
28    *   The entity type for this storage.
29    *
30    * @return \Drupal\Core\Entity\EntityStorageInterface
31    *   A storage instance.
32    *
33    * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
34    *   Thrown if the entity type doesn't exist.
35    * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
36    *   Thrown if the storage handler couldn't be loaded.
37    */
38   public function getStorage($entity_type);
39
40   /**
41    * Creates a new view builder instance.
42    *
43    * @param string $entity_type
44    *   The entity type for this view builder.
45    *
46    * @return \Drupal\Core\Entity\EntityViewBuilderInterface
47    *   A view builder instance.
48    */
49   public function getViewBuilder($entity_type);
50
51   /**
52    * Creates a new entity list builder.
53    *
54    * @param string $entity_type
55    *   The entity type for this list builder.
56    *
57    * @return \Drupal\Core\Entity\EntityListBuilderInterface
58    *   An entity list builder instance.
59    */
60   public function getListBuilder($entity_type);
61
62   /**
63    * Creates a new form instance.
64    *
65    * @param string $entity_type
66    *   The entity type for this form.
67    * @param string $operation
68    *   The name of the operation to use, e.g., 'default'.
69    *
70    * @return \Drupal\Core\Entity\EntityFormInterface
71    *   A form instance.
72    */
73   public function getFormObject($entity_type, $operation);
74
75   /**
76    * Gets all route provider instances.
77    *
78    * @param string $entity_type
79    *   The entity type for this route providers.
80    *
81    * @return \Drupal\Core\Entity\Routing\EntityRouteProviderInterface[]
82    */
83   public function getRouteProviders($entity_type);
84
85   /**
86    * Checks whether a certain entity type has a certain handler.
87    *
88    * @param string $entity_type
89    *   The name of the entity type.
90    * @param string $handler_type
91    *   The name of the handler.
92    *
93    * @return bool
94    *   Returns TRUE if the entity type has the handler, else FALSE.
95    */
96   public function hasHandler($entity_type, $handler_type);
97
98   /**
99    * Returns a handler instance for the given entity type and handler.
100    *
101    * Entity handlers are instantiated once per entity type and then cached
102    * in the entity type manager, and so subsequent calls to getHandler() for
103    * a particular entity type and handler type will return the same object.
104    * This means that properties on a handler may be used as a static cache,
105    * although as the handler is common to all entities of the same type,
106    * any data that is per-entity should be keyed by the entity ID.
107    *
108    * @param string $entity_type
109    *   The entity type for this handler.
110    * @param string $handler_type
111    *   The handler type to create an instance for.
112    *
113    * @return object
114    *   A handler instance.
115    *
116    * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
117    */
118   public function getHandler($entity_type, $handler_type);
119
120   /**
121    * Creates new handler instance.
122    *
123    * Usually \Drupal\Core\Entity\EntityManagerInterface::getHandler() is
124    * preferred since that method has additional checking that the class exists
125    * and has static caches.
126    *
127    * @param mixed $class
128    *   The handler class to instantiate.
129    * @param \Drupal\Core\Entity\EntityTypeInterface $definition
130    *   The entity type definition.
131    *
132    * @return object
133    *   A handler instance.
134    */
135   public function createHandlerInstance($class, EntityTypeInterface $definition = NULL);
136
137   /**
138    * {@inheritdoc}
139    *
140    * @return \Drupal\Core\Entity\EntityTypeInterface|null
141    */
142   public function getDefinition($entity_type_id, $exception_on_invalid = TRUE);
143
144   /**
145    * {@inheritdoc}
146    *
147    * @return \Drupal\Core\Entity\EntityTypeInterface[]
148    */
149   public function getDefinitions();
150
151 }