You are here

public function SqlContentEntityStorageSchema::requiresFieldStorageSchemaChanges in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::requiresFieldStorageSchemaChanges()

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 179
Contains \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema.

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);
}