public function FieldStorageDefinitionListener::onFieldStorageDefinitionUpdate

public FieldStorageDefinitionListener::onFieldStorageDefinitionUpdate(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original)

Reacts to the update of a field storage definition.

Parameters

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

\Drupal\Core\Field\FieldStorageDefinitionInterface $original: The original storage definition; i.e., the definition before the update.

Throws

\Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException Thrown when the update to the field is forbidden.

Overrides FieldStorageDefinitionListenerInterface::onFieldStorageDefinitionUpdate

File

core/lib/Drupal/Core/Field/FieldStorageDefinitionListener.php, line 86

Class

FieldStorageDefinitionListener
Reacts to field storage definition CRUD on behalf of the Entity system.

Namespace

Drupal\Core\Field

Code

public function onFieldStorageDefinitionUpdate(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {
  $entity_type_id = $storage_definition->getTargetEntityTypeId();

  // @todo Forward this to all interested handlers, not only storage, once
  //   iterating handlers is possible: https://www.drupal.org/node/2332857.
  $storage = $this->entityTypeManager->getStorage($entity_type_id);
  if ($storage instanceof FieldStorageDefinitionListenerInterface) {
    $storage->onFieldStorageDefinitionUpdate($storage_definition, $original);
  }

  $this->eventDispatcher->dispatch(FieldStorageDefinitionEvents::UPDATE, new FieldStorageDefinitionEvent($storage_definition, $original));

  $this->entityLastInstalledSchemaRepository->setLastInstalledFieldStorageDefinition($storage_definition);
  $this->entityFieldManager->clearCachedFieldDefinitions();
}

© 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!Field!FieldStorageDefinitionListener.php/function/FieldStorageDefinitionListener::onFieldStorageDefinitionUpdate/8.1.x