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\InvalidPluginDefinitionException
35 public function getStorage($entity_type);
38 * Creates a new view builder instance.
40 * @param string $entity_type
41 * The entity type for this view builder.
43 * @return \Drupal\Core\Entity\EntityViewBuilderInterface
44 * A view builder instance.
46 public function getViewBuilder($entity_type);
49 * Creates a new entity list builder.
51 * @param string $entity_type
52 * The entity type for this list builder.
54 * @return \Drupal\Core\Entity\EntityListBuilderInterface
55 * An entity list builder instance.
57 public function getListBuilder($entity_type);
60 * Creates a new form instance.
62 * @param string $entity_type
63 * The entity type for this form.
64 * @param string $operation
65 * The name of the operation to use, e.g., 'default'.
67 * @return \Drupal\Core\Entity\EntityFormInterface
70 public function getFormObject($entity_type, $operation);
73 * Gets all route provider instances.
75 * @param string $entity_type
76 * The entity type for this route providers.
78 * @return \Drupal\Core\Entity\Routing\EntityRouteProviderInterface[]
80 public function getRouteProviders($entity_type);
83 * Checks whether a certain entity type has a certain handler.
85 * @param string $entity_type
86 * The name of the entity type.
87 * @param string $handler_type
88 * The name of the handler.
91 * Returns TRUE if the entity type has the handler, else FALSE.
93 public function hasHandler($entity_type, $handler_type);
96 * Returns a handler instance for the given entity type and handler.
98 * Entity handlers are instantiated once per entity type and then cached
99 * in the entity type manager, and so subsequent calls to getHandler() for
100 * a particular entity type and handler type will return the same object.
101 * This means that properties on a handler may be used as a static cache,
102 * although as the handler is common to all entities of the same type,
103 * any data that is per-entity should be keyed by the entity ID.
105 * @param string $entity_type
106 * The entity type for this handler.
107 * @param string $handler_type
108 * The handler type to create an instance for.
111 * A handler instance.
113 * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
115 public function getHandler($entity_type, $handler_type);
118 * Creates new handler instance.
120 * Usually \Drupal\Core\Entity\EntityManagerInterface::getHandler() is
121 * preferred since that method has additional checking that the class exists
122 * and has static caches.
124 * @param mixed $class
125 * The handler class to instantiate.
126 * @param \Drupal\Core\Entity\EntityTypeInterface $definition
127 * The entity type definition.
130 * A handler instance.
132 public function createHandlerInstance($class, EntityTypeInterface $definition = NULL);
137 * @return \Drupal\Core\Entity\EntityTypeInterface|null
139 public function getDefinition($entity_type_id, $exception_on_invalid = TRUE);
144 * @return \Drupal\Core\Entity\EntityTypeInterface[]
146 public function getDefinitions();