EntityLastInstalledSchemaRepositoryInterface.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. namespace Drupal\Core\Entity;
  3. use Drupal\Core\Field\FieldStorageDefinitionInterface;
  4. /**
  5. * Provides an interface for an installed entity definition repository.
  6. */
  7. interface EntityLastInstalledSchemaRepositoryInterface {
  8. /**
  9. * Gets the entity type definition in its most recently installed state.
  10. *
  11. * During the application lifetime, entity type definitions can change. For
  12. * example, updated code can be deployed. The getDefinition() method will
  13. * always return the definition as determined by the current codebase. This
  14. * method, however, returns what the definition was when the last time that
  15. * one of the \Drupal\Core\Entity\EntityTypeListenerInterface events was last
  16. * fired and completed successfully. In other words, the definition that
  17. * the entity type's handlers have incorporated into the application state.
  18. * For example, if the entity type's storage handler is SQL-based, the
  19. * definition for which database tables were created.
  20. *
  21. * Application management code can check if getDefinition() differs from
  22. * getLastInstalledDefinition() and decide whether to:
  23. * - Invoke the appropriate \Drupal\Core\Entity\EntityTypeListenerInterface
  24. * event so that handlers react to the new definition.
  25. * - Raise a warning that the application state is incompatible with the
  26. * codebase.
  27. * - Perform some other action.
  28. *
  29. * @param string $entity_type_id
  30. * The entity type ID.
  31. *
  32. * @return \Drupal\Core\Entity\EntityTypeInterface|null
  33. * The installed entity type definition, or NULL if the entity type has
  34. * not yet been installed via onEntityTypeCreate().
  35. *
  36. * @see \Drupal\Core\Entity\EntityTypeListenerInterface
  37. */
  38. public function getLastInstalledDefinition($entity_type_id);
  39. /**
  40. * Gets the entity type definitions in their most recently installed state.
  41. *
  42. * During the application lifetime, entity type definitions can change. For
  43. * example, updated code can be deployed. The
  44. * \Drupal\Core\Entity\EntityTypeManagerInterface::getDefinitions() method
  45. * will always return the definitions as determined by the current codebase.
  46. * This method returns the definitions from the last time that a
  47. * \Drupal\Core\Entity\EntityTypeListener event was completed. In other words,
  48. * the definitions that the entity type's handlers have incorporated into the
  49. * application state. For example, if the entity type's storage handler is
  50. * SQL-based, the definition for which database tables were created.
  51. *
  52. * Application management code can check if
  53. * \Drupal\Core\Entity\EntityTypeManagerInterface::getDefinitions() differs
  54. * from getLastInstalledDefinitions() and decide whether to:
  55. * - Invoke the appropriate \Drupal\Core\Entity\EntityTypeListenerInterface
  56. * event so that handlers react to the new definitions.
  57. * - Raise a warning that the application state is incompatible with the
  58. * codebase.
  59. * - Perform some other action.
  60. *
  61. * @return \Drupal\Core\Entity\EntityTypeInterface[]
  62. * An array containing the installed definition for all entity types, keyed
  63. * by the entity type ID.
  64. */
  65. public function getLastInstalledDefinitions();
  66. /**
  67. * Stores the entity type definition in the application state.
  68. *
  69. * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  70. * The entity type definition.
  71. *
  72. * @return $this
  73. */
  74. public function setLastInstalledDefinition(EntityTypeInterface $entity_type);
  75. /**
  76. * Deletes the entity type definition from the application state.
  77. *
  78. * @param string $entity_type_id
  79. * The entity type definition identifier.
  80. *
  81. * @return $this
  82. */
  83. public function deleteLastInstalledDefinition($entity_type_id);
  84. /**
  85. * Gets the entity type's most recently installed field storage definitions.
  86. *
  87. * During the application lifetime, field storage definitions can change. For
  88. * example, updated code can be deployed. The getFieldStorageDefinitions()
  89. * method will always return the definitions as determined by the current
  90. * codebase. This method, however, returns what the definitions were when the
  91. * last time that one of the
  92. * \Drupal\Core\Field\FieldStorageDefinitionListenerInterface events was last
  93. * fired and completed successfully. In other words, the definitions that
  94. * the entity type's handlers have incorporated into the application state.
  95. * For example, if the entity type's storage handler is SQL-based, the
  96. * definitions for which database tables were created.
  97. *
  98. * Application management code can check if getFieldStorageDefinitions()
  99. * differs from getLastInstalledFieldStorageDefinitions() and decide whether
  100. * to:
  101. * - Invoke the appropriate
  102. * \Drupal\Core\Field\FieldStorageDefinitionListenerInterface
  103. * events so that handlers react to the new definitions.
  104. * - Raise a warning that the application state is incompatible with the
  105. * codebase.
  106. * - Perform some other action.
  107. *
  108. * @param string $entity_type_id
  109. * The entity type ID.
  110. *
  111. * @return \Drupal\Core\Field\FieldStorageDefinitionInterface[]
  112. * The array of installed field storage definitions for the entity type,
  113. * keyed by field name.
  114. *
  115. * @see \Drupal\Core\Entity\EntityTypeListenerInterface
  116. */
  117. public function getLastInstalledFieldStorageDefinitions($entity_type_id);
  118. /**
  119. * Stores the entity type's field storage definitions in the application state.
  120. *
  121. * @param string $entity_type_id
  122. * The entity type identifier.
  123. * @param \Drupal\Core\Field\FieldStorageDefinitionInterface[] $storage_definitions
  124. * An array of field storage definitions.
  125. */
  126. public function setLastInstalledFieldStorageDefinitions($entity_type_id, array $storage_definitions);
  127. /**
  128. * Stores the field storage definition in the application state.
  129. *
  130. * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
  131. * The field storage definition.
  132. */
  133. public function setLastInstalledFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition);
  134. /**
  135. * Deletes the field storage definition from the application state.
  136. *
  137. * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
  138. * The field storage definition.
  139. */
  140. public function deleteLastInstalledFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition);
  141. }