You are here

public function SqlContentEntityStorageSchema::requiresFieldStorageSchemaChanges in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::requiresFieldStorageSchemaChanges()
  2. 9 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 261

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
    ->getTableMapping($this->entityType);
  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;
  }
  $current_schema = $this
    ->getSchemaFromStorageDefinition($storage_definition);
  $this
    ->processFieldStorageSchema($current_schema);
  $installed_schema = $this
    ->loadFieldSchemaData($original);
  $this
    ->processFieldStorageSchema($installed_schema);
  return $current_schema != $installed_schema;
}