EntityTypeManagerInterface.php 4.2 KB

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