public function SqlContentEntityStorageSchema::requiresFieldStorageSchemaChanges

public SqlContentEntityStorageSchema::requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original)

Checks if the changes to the storage definition requires schema changes.

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The updated field storage definition.

\Drupal\Core\Field\FieldStorageDefinitionInterface $original: The original field storage definition.

Return value

bool TRUE if storage schema changes are required, FALSE otherwise.

Overrides DynamicallyFieldableEntityStorageSchemaInterface::requiresFieldStorageSchemaChanges

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php, line 174

Class

SqlContentEntityStorageSchema
Defines a schema handler that supports revisionable, translatable entities.

Namespace

Drupal\Core\Entity\Sql

Code

public function requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {
  $table_mapping = $this->storage->getTableMapping();

  if (
  $storage_definition->hasCustomStorage() != $original->hasCustomStorage() || 
    $storage_definition->getSchema() != $original->getSchema() || 
    $storage_definition->isRevisionable() != $original->isRevisionable() || 
    $table_mapping->allowsSharedTableStorage($storage_definition) != $table_mapping->allowsSharedTableStorage($original) || 
    $table_mapping->requiresDedicatedTableStorage($storage_definition) != $table_mapping->requiresDedicatedTableStorage($original)
    ) {
    return TRUE;
  }

  if ($storage_definition->hasCustomStorage()) {
    // The field has custom storage, so we don't know if a schema change is
    // needed or not, but since per the initial checks earlier in this
    // function, nothing about the definition changed that we manage, we
    // return FALSE.
    return FALSE;
  }

  return $this->getSchemaFromStorageDefinition($storage_definition) != $this->loadFieldSchemaData($original);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Sql!SqlContentEntityStorageSchema.php/function/SqlContentEntityStorageSchema::requiresFieldStorageSchemaChanges/8.1.x