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 * Gets the entity type definitions in their most recently installed state.
47 * During the application lifetime, entity type definitions can change. For
48 * example, updated code can be deployed. The
49 * \Drupal\Core\Entity\EntityTypeManagerInterface::getDefinitions() method
50 * will always return the definitions as determined by the current codebase.
51 * This method returns the definitions from the last time that a
52 * \Drupal\Core\Entity\EntityTypeListener event was completed. In other words,
53 * the definitions that the entity type's handlers have incorporated into the
54 * application state. For example, if the entity type's storage handler is
55 * SQL-based, the definition for which database tables were created.
57 * Application management code can check if
58 * \Drupal\Core\Entity\EntityTypeManagerInterface::getDefinitions() differs
59 * from getLastInstalledDefinitions() and decide whether to:
60 * - Invoke the appropriate \Drupal\Core\Entity\EntityTypeListenerInterface
61 * event so that handlers react to the new definitions.
62 * - Raise a warning that the application state is incompatible with the
64 * - Perform some other action.
66 * @return \Drupal\Core\Entity\EntityTypeInterface[]
67 * An array containing the installed definition for all entity types, keyed
68 * by the entity type ID.
70 public function getLastInstalledDefinitions();
73 * Stores the entity type definition in the application state.
75 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
76 * The entity type definition.
80 public function setLastInstalledDefinition(EntityTypeInterface $entity_type);
83 * Deletes the entity type definition from the application state.
85 * @param string $entity_type_id
86 * The entity type definition identifier.
90 public function deleteLastInstalledDefinition($entity_type_id);
93 * Gets the entity type's most recently installed field storage definitions.
95 * During the application lifetime, field storage definitions can change. For
96 * example, updated code can be deployed. The getFieldStorageDefinitions()
97 * method will always return the definitions as determined by the current
98 * codebase. This method, however, returns what the definitions were when the
99 * last time that one of the
100 * \Drupal\Core\Field\FieldStorageDefinitionListenerInterface events was last
101 * fired and completed successfully. In other words, the definitions that
102 * the entity type's handlers have incorporated into the application state.
103 * For example, if the entity type's storage handler is SQL-based, the
104 * definitions for which database tables were created.
106 * Application management code can check if getFieldStorageDefinitions()
107 * differs from getLastInstalledFieldStorageDefinitions() and decide whether
109 * - Invoke the appropriate
110 * \Drupal\Core\Field\FieldStorageDefinitionListenerInterface
111 * events so that handlers react to the new definitions.
112 * - Raise a warning that the application state is incompatible with the
114 * - Perform some other action.
116 * @param string $entity_type_id
117 * The entity type ID.
119 * @return \Drupal\Core\Field\FieldStorageDefinitionInterface[]
120 * The array of installed field storage definitions for the entity type,
121 * keyed by field name.
123 * @see \Drupal\Core\Entity\EntityTypeListenerInterface
125 public function getLastInstalledFieldStorageDefinitions($entity_type_id);
128 * Stores the entity type's field storage definitions in the application state.
130 * @param string $entity_type_id
131 * The entity type identifier.
132 * @param \Drupal\Core\Field\FieldStorageDefinitionInterface[] $storage_definitions
133 * An array of field storage definitions.
135 public function setLastInstalledFieldStorageDefinitions($entity_type_id, array $storage_definitions);
138 * Stores the field storage definition in the application state.
140 * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
141 * The field storage definition.
143 public function setLastInstalledFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition);
146 * Deletes the field storage definition from the application state.
148 * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
149 * The field storage definition.
151 public function deleteLastInstalledFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition);