EntityTypeRepositoryInterface.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Drupal\Core\Entity;
  3. /**
  4. * Provides an interface for helper methods for loading entity types.
  5. */
  6. interface EntityTypeRepositoryInterface {
  7. /**
  8. * Builds a list of entity type labels suitable for a Form API options list.
  9. *
  10. * @param bool $group
  11. * (optional) Whether to group entity types by plugin group (e.g. 'content',
  12. * 'config'). Defaults to FALSE.
  13. *
  14. * @return array
  15. * An array of entity type labels, keyed by entity type name.
  16. */
  17. public function getEntityTypeLabels($group = FALSE);
  18. /**
  19. * Gets the entity type ID based on the class that is called on.
  20. *
  21. * Compares the class this is called on against the known entity classes
  22. * and returns the entity type ID of a direct match or a subclass as fallback,
  23. * to support entity type definitions that were altered.
  24. *
  25. * @param string $class_name
  26. * Class name to use for searching the entity type ID.
  27. *
  28. * @return string
  29. * The entity type ID.
  30. *
  31. * @throws \Drupal\Core\Entity\Exception\AmbiguousEntityClassException
  32. * Thrown when multiple subclasses correspond to the called class.
  33. * @throws \Drupal\Core\Entity\Exception\NoCorrespondingEntityClassException
  34. * Thrown when no entity class corresponds to the called class.
  35. *
  36. * @see \Drupal\Core\Entity\Entity::load()
  37. * @see \Drupal\Core\Entity\Entity::loadMultiple()
  38. */
  39. public function getEntityTypeFromClass($class_name);
  40. /**
  41. * Clear the static cache.
  42. *
  43. * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
  44. *
  45. * @todo Remove in https://www.drupal.org/node/2549143.
  46. */
  47. public function clearCachedDefinitions();
  48. }