3 namespace Drupal\Core\Entity;
5 use Drupal\Core\Field\FieldStorageDefinitionInterface;
8 * Provides an interface for an installed entity definition repository.
10 interface EntityLastInstalledSchemaRepositoryInterface {
13 * Gets the entity type definition in its most recently installed state.
15 * During the application lifetime, entity type definitions can change. For
16 * example, updated code can be deployed. The getDefinition() method will
17 * always return the definition as determined by the current codebase. This
18 * method, however, returns what the definition was when the last time that
19 * one of the \Drupal\Core\Entity\EntityTypeListenerInterface events was last
20 * fired and completed successfully. In other words, the definition that
21 * the entity type's handlers have incorporated into the application state.
22 * For example, if the entity type's storage handler is SQL-based, the
23 * definition for which database tables were created.
25 * Application management code can check if getDefinition() differs from
26 * getLastInstalledDefinition() and decide whether to:
27 * - Invoke the appropriate \Drupal\Core\Entity\EntityTypeListenerInterface
28 * event so that handlers react to the new definition.
29 * - Raise a warning that the application state is incompatible with the
31 * - Perform some other action.
33 * @param string $entity_type_id
36 * @return \Drupal\Core\Entity\EntityTypeInterface|null
37 * The installed entity type definition, or NULL if the entity type has
38 * not yet been installed via onEntityTypeCreate().
40 * @see \Drupal\Core\Entity\EntityTypeListenerInterface
42 public function getLastInstalledDefinition($entity_type_id);
45 * Stores the entity type definition in the application state.
47 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
48 * The entity type definition.
52 public function setLastInstalledDefinition(EntityTypeInterface $entity_type);
55 * Deletes the entity type definition from the application state.
57 * @param string $entity_type_id
58 * The entity type definition identifier.
62 public function deleteLastInstalledDefinition($entity_type_id);
65 * Gets the entity type's most recently installed field storage definitions.
67 * During the application lifetime, field storage definitions can change. For
68 * example, updated code can be deployed. The getFieldStorageDefinitions()
69 * method will always return the definitions as determined by the current
70 * codebase. This method, however, returns what the definitions were when the
71 * last time that one of the
72 * \Drupal\Core\Field\FieldStorageDefinitionListenerInterface events was last
73 * fired and completed successfully. In other words, the definitions that
74 * the entity type's handlers have incorporated into the application state.
75 * For example, if the entity type's storage handler is SQL-based, the
76 * definitions for which database tables were created.
78 * Application management code can check if getFieldStorageDefinitions()
79 * differs from getLastInstalledFieldStorageDefinitions() and decide whether
81 * - Invoke the appropriate
82 * \Drupal\Core\Field\FieldStorageDefinitionListenerInterface
83 * events so that handlers react to the new definitions.
84 * - Raise a warning that the application state is incompatible with the
86 * - Perform some other action.
88 * @param string $entity_type_id
91 * @return \Drupal\Core\Field\FieldStorageDefinitionInterface[]
92 * The array of installed field storage definitions for the entity type,
93 * keyed by field name.
95 * @see \Drupal\Core\Entity\EntityTypeListenerInterface
97 public function getLastInstalledFieldStorageDefinitions($entity_type_id);
100 * Stores the entity type's field storage definitions in the application state.
102 * @param string $entity_type_id
103 * The entity type identifier.
104 * @param \Drupal\Core\Field\FieldStorageDefinitionInterface[] $storage_definitions
105 * An array of field storage definitions.
107 public function setLastInstalledFieldStorageDefinitions($entity_type_id, array $storage_definitions);
110 * Stores the field storage definition in the application state.
112 * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
113 * The field storage definition.
115 public function setLastInstalledFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition);
118 * Deletes the field storage definition from the application state.
120 * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
121 * The field storage definition.
123 public function deleteLastInstalledFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition);