You are here

public function ConsumerStorage::restore in Consumers 8

Restores a previously saved entity.

Note that the entity is assumed to be in a valid state for the storage, so the restore process does not invoke any hooks, nor does it perform any pre or post-save operations.

@internal This method should never be used to perform a regular entity save. Its only use-case is to assist updating entity types when there are complex schema changes, for example, to make them revisionable. Note that overriding this method to fix data prior to restoring is a likely sign that the current data is corrupt.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to restore.

Throws

\Drupal\Core\Entity\EntityStorageException In case of failures, an exception is thrown.

Overrides SqlContentEntityStorage::restore

File

src/ConsumerStorage.php, line 13

Class

ConsumerStorage

Namespace

Drupal\consumers

Code

public function restore(EntityInterface $entity) {

  /** @var \Drupal\consumers\Entity\Consumer $entity */

  // Special handling for the secret field added by simple_oauth, make sure that it is not hashed again.
  if ($entity
    ->hasField('secret')) {
    $entity
      ->get('secret')->pre_hashed = TRUE;
  }
  parent::restore($entity);
}