diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php index c73a5c1..df6c3a7 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php @@ -12,9 +12,9 @@ use Drupal\Core\Database\Database; use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Entity\Schema\ContentEntitySchemaHandler; -use Drupal\Core\Entity\Schema\ContentEntitySchemaHandlerInterface; +use Drupal\Core\Entity\Schema\EntitySchemaProviderInterface; use Drupal\Core\Entity\Sql\DefaultTableMapping; -use Drupal\Core\Entity\Sql\SqlStorageInterface; +use Drupal\Core\Entity\Sql\SqlEntityStorageInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Language\Language; @@ -32,14 +32,14 @@ * This class can be used as-is by most simple entity types. Entity types * requiring special handling can extend the class. */ -class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements SqlStorageInterface, ContentEntitySchemaHandlerInterface { +class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements SqlEntityStorageInterface, EntitySchemaProviderInterface { /** * The base field definitions for this entity type. * * @var \Drupal\Core\Field\FieldStorageDefinitionInterface[] */ - protected $storageDefinitions; + protected $fieldStorageDefinitions; /** * A mapping of schema fields that will be stored per entity table. @@ -109,7 +109,7 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S /** * The entity schema handler. * - * @var \Drupal\Core\Entity\Schema\ContentEntitySchemaHandlerInterface + * @var \Drupal\Core\Entity\Schema\EntitySchemaHandlerInterface */ protected $schemaHandler; @@ -143,7 +143,7 @@ public function __construct(EntityTypeInterface $entity_type, Connection $databa // @todo Remove the check for FieldDefinitionInterface::isMultiple() when // multiple-value base fields are supported in // https://drupal.org/node/2248977. - $this->storageDefinitions = array_filter($entity_manager->getBaseFieldDefinitions($entity_type->id()), function (FieldDefinitionInterface $definition) { + $this->fieldStorageDefinitions = array_filter($entity_manager->getBaseFieldDefinitions($entity_type->id()), function (FieldDefinitionInterface $definition) { return !$definition->isComputed() && !$definition->hasCustomStorage() && !$definition->isMultiple(); }); @@ -236,11 +236,11 @@ protected function schemaHandler() { */ public function getTableMapping() { if (!isset($this->tableMapping)) { - $this->tableMapping = new DefaultTableMapping($this->storageDefinitions); + $this->tableMapping = new DefaultTableMapping($this->fieldStorageDefinitions); $key_fields = array_values(array_filter(array($this->idKey, $this->revisionKey, $this->bundleKey, $this->uuidKey, $this->langcodeKey))); - $all_fields = array_keys($this->storageDefinitions); - $revisionable_fields = array_keys(array_filter($this->storageDefinitions, function (FieldStorageDefinitionInterface $definition) { + $all_fields = array_keys($this->fieldStorageDefinitions); + $revisionable_fields = array_keys(array_filter($this->fieldStorageDefinitions, function (FieldStorageDefinitionInterface $definition) { return $definition->isRevisionable(); })); // Make sure the key fields come first in the list of fields. @@ -827,10 +827,10 @@ protected function mapToStorageRecord(ContentEntityInterface $entity, $table_nam $table_mapping = $this->getTableMapping(); foreach ($table_mapping->getFieldNames($table_name) as $field_name) { - if (empty($this->storageDefinitions[$field_name])) { + if (empty($this->fieldStorageDefinitions[$field_name])) { throw new EntityStorageException(String::format('Table mapping contains invalid field %field.', array('%field' => $field_name))); } - $definition = $this->storageDefinitions[$field_name]; + $definition = $this->fieldStorageDefinitions[$field_name]; $columns = $table_mapping->getColumnNames($field_name); foreach ($columns as $column_name => $schema_name) { diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php index 9847483..54664d1 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php @@ -12,7 +12,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Entity\Query\QueryException; -use Drupal\Core\Entity\Sql\SqlStorageInterface; +use Drupal\Core\Entity\Sql\SqlEntityStorageInterface; use Drupal\field\Entity\FieldConfig; use Drupal\field\FieldConfigInterface; @@ -262,7 +262,7 @@ protected function getTableMapping($table, $entity_type_id) { // @todo Stop calling drupal_get_schema() once menu links are converted // to the Entity Field API. See https://drupal.org/node/1842858. $schema = drupal_get_schema($table); - if (!$schema && $storage instanceof SqlStorageInterface) { + if (!$schema && $storage instanceof SqlEntityStorageInterface) { $mapping = $storage->getTableMapping()->getAllColumns($table); } else { diff --git a/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php b/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php index 9fa1d95..22e7629 100644 --- a/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php +++ b/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php @@ -13,7 +13,7 @@ /** * An entity schema builder that supports revisionable, translatable entities. */ -class ContentEntitySchemaHandler implements ContentEntitySchemaHandlerInterface { +class ContentEntitySchemaHandler implements EntitySchemaHandlerInterface { /** * The entity type this schema builder is responsible for. @@ -27,7 +27,7 @@ class ContentEntitySchemaHandler implements ContentEntitySchemaHandlerInterface * * @var \Drupal\Core\Field\FieldDefinitionInterface[] */ - protected $storageDefinitions; + protected $fieldStorageDefinitions; /** * The storage object for the given entity type. @@ -55,7 +55,7 @@ class ContentEntitySchemaHandler implements ContentEntitySchemaHandlerInterface */ public function __construct(EntityManagerInterface $entity_manager, ContentEntityTypeInterface $entity_type, ContentEntityDatabaseStorage $storage) { $this->entityType = $entity_type; - $this->storageDefinitions = $entity_manager->getFieldStorageDefinitions($entity_type->id()); + $this->fieldStorageDefinitions = $entity_manager->getFieldStorageDefinitions($entity_type->id()); $this->storage = $storage; } @@ -139,8 +139,8 @@ protected function getTables() { * A mapping of field column names to database column names. */ protected function addFieldSchema(array &$schema, $field_name, array $column_mapping) { - $field_schema = $this->storageDefinitions[$field_name]->getSchema(); - $field_description = $this->storageDefinitions[$field_name]->getDescription(); + $field_schema = $this->fieldStorageDefinitions[$field_name]->getSchema(); + $field_description = $this->fieldStorageDefinitions[$field_name]->getDescription(); foreach ($column_mapping as $field_column_name => $schema_field_name) { $column_schema = $field_schema['columns'][$field_column_name]; diff --git a/core/lib/Drupal/Core/Entity/Schema/EntitySchemaHandlerInterface.php b/core/lib/Drupal/Core/Entity/Schema/EntitySchemaHandlerInterface.php new file mode 100644 index 0000000..a151a29 --- /dev/null +++ b/core/lib/Drupal/Core/Entity/Schema/EntitySchemaHandlerInterface.php @@ -0,0 +1,12 @@ +storageDefinitions = $storage_definitions; + $this->fieldStorageDefinitions = $storage_definitions; } /** @@ -118,7 +118,7 @@ public function getFieldNames($table_name) { */ public function getColumnNames($field_name) { if (!isset($this->columnMapping[$field_name])) { - $column_names = array_keys($this->storageDefinitions[$field_name]->getColumns()); + $column_names = array_keys($this->fieldStorageDefinitions[$field_name]->getColumns()); if (count($column_names) == 1) { $this->columnMapping[$field_name] = array(reset($column_names) => $field_name); } diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlStorageInterface.php b/core/lib/Drupal/Core/Entity/Sql/SqlEntityStorageInterface.php similarity index 74% rename from core/lib/Drupal/Core/Entity/Sql/SqlStorageInterface.php rename to core/lib/Drupal/Core/Entity/Sql/SqlEntityStorageInterface.php index 8a0bc1b..c8ab0d7 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlStorageInterface.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlEntityStorageInterface.php @@ -1,7 +1,7 @@ getDefinitions() as $entity_type) { if ($entity_type->getProvider() == $module) { $storage = $entity_manager->getStorage($entity_type->id()); - if ($storage instanceof ContentEntitySchemaHandlerInterface) { + if ($storage instanceof EntitySchemaProviderInterface) { foreach ($storage->getSchema() as $table_name => $table_schema) { if (!$schema->tableExists($table_name)) { $schema->createTable($table_name, $table_schema); @@ -914,7 +914,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { foreach ($entity_manager->getDefinitions() as $entity_type) { if ($entity_type->getProvider() == $module) { $storage = $entity_manager->getStorage($entity_type->id()); - if ($storage instanceof ContentEntitySchemaHandlerInterface) { + if ($storage instanceof EntitySchemaProviderInterface) { foreach ($storage->getSchema() as $table_name => $table_schema) { if ($schema->tableExists($table_name)) { $schema->dropTable($table_name); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/KernelTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/KernelTestBase.php index f1f4efb..2606747 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/KernelTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/KernelTestBase.php @@ -13,7 +13,7 @@ use Drupal\Core\DrupalKernel; use Drupal\Core\KeyValueStore\KeyValueMemoryFactory; use Drupal\Core\Language\Language; -use Drupal\Core\Entity\Schema\ContentEntitySchemaHandlerInterface; +use Drupal\Core\Entity\Schema\EntitySchemaProviderInterface; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpFoundation\Request; @@ -355,7 +355,7 @@ protected function installEntitySchema($entity_type_id) { $schema_handler = $this->container->get('database')->schema(); $storage = $entity_manager->getStorage($entity_type_id); - if ($storage instanceof ContentEntitySchemaHandlerInterface) { + if ($storage instanceof EntitySchemaProviderInterface) { $schema = $storage->getSchema(); foreach ($schema as $table_name => $table_schema) { $schema_handler->createTable($table_name, $table_schema); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/KernelTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/KernelTestBaseTest.php index d690011..1537393 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/KernelTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/KernelTestBaseTest.php @@ -75,7 +75,7 @@ function testEnableModulesLoad() { */ function testEnableModulesInstall() { $module = 'node'; - $table = 'node'; + $table = 'node_access'; // Verify that the module does not exist yet. $this->assertFalse(\Drupal::moduleHandler()->moduleExists($module), "$module module not found."); diff --git a/core/modules/user/lib/Drupal/user/UserStorage.php b/core/modules/user/lib/Drupal/user/UserStorage.php index 544971f..44d323f 100644 --- a/core/modules/user/lib/Drupal/user/UserStorage.php +++ b/core/modules/user/lib/Drupal/user/UserStorage.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\Schema\ContentEntitySchemaHandlerInterface; use Drupal\Core\Password\PasswordInterface; use Drupal\Core\Database\Connection; use Symfony\Component\DependencyInjection\ContainerInterface;