Issue #2330121 by plach, effulgentsia, fago: Replace ContentEntityDatabaseStorage::getSchema() with a new EntityTypeListenerInterface implemented by SqlContentEntityStorageSchema.
$entity_storage->getSchema() to get a Schema API array, and then communicate with the database to create/drop those tables. That division of responsibility makes no sense. Why should ModuleHandler and all other callers bias SQL-based storage in such a way? Better for it to tell the storage handler that an entity type definition is being created, updated, or deleted, and let the storage handler decide how to implement that. This refactor becomes especially important for implementing the update operation (not part of the scope of this child issue), which is quite involved and needs to be encapsulated.
Replace the SQL-specific getSchema() method with the more generic
onEntityType(Create|Update|Delete)() methods that can be implemented by any storage system. See "API changes" for details.
User interface changes
- Removes EntitySchemaProviderInterface. This just had the getSchema() method that we are removing.
- Removes EntitySchemaHandlerInterface. Same as above.
- Adds an EnityTypeListenerInterface for reacting to creation, deletion, and updates of entity types. Makes SqlContentEntityStorageSchema implement this interface. Getting the schema is no longer part of SqlContentEntityStorageSchema's interface, it is a protected implementation detail.
- Also makes ContentEntityDatabaseStorage and EntityManager implement EnityTypeListenerInterface. Thereby, outside code invokes the methods on EntityManager, which forwards to the storage handler, and ContentEntityDatabaseStorage forwards to the schema handler.
- Changes former callers of EntitySchemaProviderInterface::getSchema() (e.g., ModuleHandler, KernelTestBase, contact_storage_test.install, and tests) to call the new EnityTypeListenerInterface methods on EntityManager (outside of unit tests) or the handler being tested (within unit tests) instead.
|PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 75,835 pass(es). |
[ View ]
|PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 75,829 pass(es). |
[ View ]