ConfigEntityTypeInterface.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace Drupal\Core\Config\Entity;
  3. use Drupal\Core\Entity\EntityTypeInterface;
  4. /**
  5. * Provides an interface for a configuration entity type and its metadata.
  6. */
  7. interface ConfigEntityTypeInterface extends EntityTypeInterface {
  8. /**
  9. * Length limit of the configuration entity prefix.
  10. *
  11. * Configuration entity names are composed of two parts:
  12. * - The config prefix, which is returned by getConfigPrefix() and is
  13. * composed of:
  14. * - The provider module name (limited to 50 characters by
  15. * DRUPAL_EXTENSION_NAME_MAX_LENGTH).
  16. * - The module-specific namespace identifier, which defaults to the
  17. * configuration entity type ID. Entity type IDs are limited to 32
  18. * characters by EntityTypeInterface::ID_MAX_LENGTH.
  19. * - The configuration entity ID.
  20. * So, a typical configuration entity filename will look something like:
  21. * provider_module_name.namespace_identifier.config_entity_id.yml
  22. *
  23. * Most file systems limit a file name's length to 255 characters, so
  24. * ConfigBase::MAX_NAME_LENGTH restricts the full configuration object name
  25. * to 250 characters (leaving 5 for the file extension). Therefore, in
  26. * order to leave sufficient characters to construct a configuration ID,
  27. * the configuration entity prefix is limited to 83 characters: up to 50
  28. * characters for the module name, 1 for the dot, and 32 for the namespace
  29. * identifier. This also allows modules with shorter names to define longer
  30. * namespace identifiers if desired.
  31. *
  32. * @see \Drupal\Core\Config\ConfigBase::MAX_NAME_LENGTH
  33. * @see \Drupal\Core\Config\Entity\ConfigEntityTypeInterface::getConfigPrefix()
  34. * @see DRUPAL_EXTENSION_NAME_MAX_LENGTH
  35. * @see \Drupal\Core\Config\Entity\ConfigEntityStorage::MAX_ID_LENGTH
  36. * @see \Drupal\Core\Entity\EntityTypeInterface::ID_MAX_LENGTH
  37. */
  38. const PREFIX_LENGTH = 83;
  39. /**
  40. * Gets the config prefix used by the configuration entity type.
  41. *
  42. * The config prefix is used to prefix configuration entity IDs when they are
  43. * stored in the configuration system. The default config prefix is
  44. * constructed from the name of the module that provides the entity type and
  45. * the ID of the entity type. If a config_prefix annotation is present it will
  46. * be used in place of the entity type ID.
  47. *
  48. * Prefixing with the module that provides the configuration entity type
  49. * ensures that configuration entities depend on the module that provides the
  50. * configuration entity type.
  51. *
  52. * @return string
  53. * The config prefix.
  54. *
  55. * @throws \Drupal\Core\Config\ConfigPrefixLengthException
  56. * Exception thrown when the length of the prefix exceeds PREFIX_LENGTH.
  57. */
  58. public function getConfigPrefix();
  59. /**
  60. * Gets the config entity properties to export if declared on the annotation.
  61. *
  62. * Falls back to determining the properties using configuration schema, if the
  63. * config entity properties are not declared.
  64. *
  65. * @param string $id
  66. * The ID of the configuration entity. Used when checking schema instead of
  67. * the annotation.
  68. *
  69. * @return array|null
  70. * The properties to export or NULL if they can not be determine from the
  71. * config entity type annotation or the schema.
  72. */
  73. public function getPropertiesToExport($id = NULL);
  74. /**
  75. * Gets the keys that are available for fast lookup.
  76. *
  77. * @return string[]
  78. * The list of lookup keys.
  79. */
  80. public function getLookupKeys();
  81. }