diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php index 2666620..95abb36 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php @@ -32,36 +32,6 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements ContentEntitySchemaHandlerInterface, SqlStorageInterface { /** - * The base table layout: no revision or multilingual support for base fields. - * - * @var int - */ - const LAYOUT_BASE = 0; - - /** - * The revision table layout: provides revision support for base fields. - * - * @var int - */ - const LAYOUT_REVISION = 1; - - /** - * The multilingual table layout: provides multilingual support for base - * fields. - * - * @var int - */ - const LAYOUT_MULTILINGUAL = 2; - - /** - * The multilingual revision table layout: provides revision and multilingual - * support for base fields. - * - * @var int - */ - const LAYOUT_MULTILINGUAL_REVISION = 3; - - /** * The base field definitions for this entity type. * * @var \Drupal\Core\Field\FieldDefinitionInterface[] @@ -234,15 +204,7 @@ protected function initTableLayout() { } /** - * Returns the current layout type. - * - * @return int - * An integer value identifiying the current layour type. - * - * @see static::LAYOUT_BASE - * @see static::LAYOUT_REVISION - * @see static::LAYOUT_MULTILINGUAL - * @see static::LAYOUT_MULTILINGUAL_REVISION + * {@inheritdoc} */ public function getLayoutType() { if (!isset($this->layoutType)) { @@ -263,40 +225,28 @@ public function getLayoutType() { } /** - * Returns the base table name. - * - * @return string - * The table name. + * {@inheritdoc} */ public function getBaseTable() { return $this->baseTable; } /** - * Returns the revision table name. - * - * @return string|bool - * The table name or FALSE if it is not available. + * {@inheritdoc} */ public function getRevisionTable() { return $this->revisionTable; } /** - * Returns the data table name. - * - * @return string|bool - * The table name or FALSE if it is not available. + * {@inheritdoc} */ public function getDataTable() { return $this->dataTable; } /** - * Returns the revision data table name. - * - * @return string|bool - * The table name or FALSE if it is not available. + * {@inheritdoc} */ public function getRevisionDataTable() { return $this->revisionDataTable; diff --git a/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php b/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php index 2c19d07..86d9806 100644 --- a/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php +++ b/core/lib/Drupal/Core/Entity/Schema/ContentEntitySchemaHandler.php @@ -9,8 +9,8 @@ use Drupal\Core\Entity\ContentEntityType; use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\SqlStorageInterface; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Entity\EntityTypeInterface; /** * An entity schema builder that supports revisionable, translatable entities. @@ -52,8 +52,10 @@ class ContentEntitySchemaHandler implements ContentEntitySchemaHandlerInterface * The entity manager. * @param \Drupal\Core\Entity\ContentEntityType $entity_type * The entity type. + * @param \Drupal\Core\Entity\SqlStorageInterface $storage + * The storage of the entity type. This must be an SQL-based storage. */ - public function __construct(EntityManagerInterface $entity_manager, ContentEntityType $entity_type, ContentEntityDatabaseStorage $storage) { + public function __construct(EntityManagerInterface $entity_manager, ContentEntityType $entity_type, SqlStorageInterface $storage) { $this->entityType = $entity_type; $this->fieldDefinitions = $entity_manager->getBaseFieldDefinitions($entity_type->id()); $this->storage = $storage; diff --git a/core/lib/Drupal/Core/Entity/SqlStorageInterface.php b/core/lib/Drupal/Core/Entity/SqlStorageInterface.php index 4bff3c2..d400ddc 100644 --- a/core/lib/Drupal/Core/Entity/SqlStorageInterface.php +++ b/core/lib/Drupal/Core/Entity/SqlStorageInterface.php @@ -12,6 +12,80 @@ interface SqlStorageInterface { /** + * The base table layout: no revision or multilingual support for base fields. + * + * @var int + */ + const LAYOUT_BASE = 0; + + /** + * The revision table layout: provides revision support for base fields. + * + * @var int + */ + const LAYOUT_REVISION = 1; + + /** + * The multilingual table layout: provides multilingual support for base + * fields. + * + * @var int + */ + const LAYOUT_MULTILINGUAL = 2; + + /** + * The multilingual revision table layout: provides revision and multilingual + * support for base fields. + * + * @var int + */ + const LAYOUT_MULTILINGUAL_REVISION = 3; + + /** + * Returns the current layout type. + * + * @return int + * An integer value identifying the current layout type. + * + * @see static::LAYOUT_BASE + * @see static::LAYOUT_REVISION + * @see static::LAYOUT_MULTILINGUAL + * @see static::LAYOUT_MULTILINGUAL_REVISION + */ + public function getLayoutType(); + + /** + * Returns the base table name. + * + * @return string + * The table name. + */ + public function getBaseTable(); + + /** + * Returns the revision table name. + * + * @return string|bool + * The table name or FALSE if it is not available. + */ + public function getRevisionTable(); + /** + * Returns the data table name. + * + * @return string|bool + * The table name or FALSE if it is not available. + */ + public function getDataTable(); + + /** + * Returns the revision data table name. + * + * @return string|bool + * The table name or FALSE if it is not available. + */ + public function getRevisionDataTable(); + + /** * Gets a mapping of schema fields that will be stored per entity table. * * @return array diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php index fb1087f..4f8314e 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php @@ -81,7 +81,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Name')) ->setDescription(t('The name of the test entity.')) ->setTranslatable(TRUE) - ->setSetting('max_length', 32); + ->setSetting('max_length', EntityTypeInterface::BUNDLE_MAX_LENGTH); // @todo: Add allowed values validation. $fields['type'] = FieldDefinition::create('string')