3 namespace Drupal\Core\Entity;
5 use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
6 use Drupal\Component\Plugin\PluginManagerInterface;
9 * Provides an interface for entity type managers.
11 interface EntityTypeManagerInterface extends PluginManagerInterface, CachedDiscoveryInterface {
14 * Creates a new access control handler instance.
16 * @param string $entity_type
17 * The entity type for this access control handler.
19 * @return \Drupal\Core\Entity\EntityAccessControlHandlerInterface
20 * A access control handler instance.
22 public function getAccessControlHandler($entity_type);
25 * Creates a new storage instance.
27 * @param string $entity_type
28 * The entity type for this storage.
30 * @return \Drupal\Core\Entity\EntityStorageInterface
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.
38 public function getStorage($entity_type);
41 * Creates a new view builder instance.
43 * @param string $entity_type
44 * The entity type for this view builder.
46 * @return \Drupal\Core\Entity\EntityViewBuilderInterface
47 * A view builder instance.
49 public function getViewBuilder($entity_type);
52 * Creates a new entity list builder.
54 * @param string $entity_type
55 * The entity type for this list builder.
57 * @return \Drupal\Core\Entity\EntityListBuilderInterface
58 * An entity list builder instance.
60 public function getListBuilder($entity_type);
63 * Creates a new form instance.
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'.
70 * @return \Drupal\Core\Entity\EntityFormInterface
73 public function getFormObject($entity_type, $operation);
76 * Gets all route provider instances.
78 * @param string $entity_type
79 * The entity type for this route providers.
81 * @return \Drupal\Core\Entity\Routing\EntityRouteProviderInterface[]
83 public function getRouteProviders($entity_type);
86 * Checks whether a certain entity type has a certain handler.
88 * @param string $entity_type
89 * The name of the entity type.
90 * @param string $handler_type
91 * The name of the handler.
94 * Returns TRUE if the entity type has the handler, else FALSE.
96 public function hasHandler($entity_type, $handler_type);
99 * Returns a handler instance for the given entity type and handler.
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.
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.
114 * A handler instance.
116 * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
118 public function getHandler($entity_type, $handler_type);
121 * Creates new handler instance.
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.
127 * @param mixed $class
128 * The handler class to instantiate.
129 * @param \Drupal\Core\Entity\EntityTypeInterface $definition
130 * The entity type definition.
133 * A handler instance.
135 public function createHandlerInstance($class, EntityTypeInterface $definition = NULL);
140 * @return \Drupal\Core\Entity\EntityTypeInterface|null
142 public function getDefinition($entity_type_id, $exception_on_invalid = TRUE);
147 * @return \Drupal\Core\Entity\EntityTypeInterface[]
149 public function getDefinitions();