EntityTypeManagerInterface.php 4.4 KB

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