You are here

public function InvalidationsService::getImmutableFromQueueData in Purge 8.3

Replicate a immutable invalidation object from serialized queue item data.

Parameters

string $item_data: Arbitrary PHP data structured that was stored into the queue.

Return value

\Drupal\purge\Plugin\Purge\Invalidation\ImmutableInvalidationInterface The immutable invalidation object.

Throws

\Drupal\purge\Plugin\Purge\Invalidation\Exception\MissingExpressionException Thrown when plugin defined expression_required = TRUE and when it is instantiated without expression (NULL).

\Drupal\purge\Plugin\Purge\Invalidation\Exception\InvalidExpressionException Exception thrown when plugin got instantiated with an expression that is not deemed valid for the type of invalidation.

Overrides InvalidationsServiceInterface::getImmutableFromQueueData

File

src/Plugin/Purge/Invalidation/InvalidationsService.php, line 134

Class

InvalidationsService
Provides a service that instantiates invalidation objects on-demand.

Namespace

Drupal\purge\Plugin\Purge\Invalidation

Code

public function getImmutableFromQueueData($item_data) {
  $instance = $this
    ->createInstance($item_data[ProxyItemInterface::DATA_INDEX_TYPE], $item_data[ProxyItemInterface::DATA_INDEX_EXPRESSION], $this->instanceCounterImmutables--);

  // Replay stored purger states.
  if (isset($item_data[ProxyItemInterface::DATA_INDEX_STATES])) {
    foreach ($item_data[ProxyItemInterface::DATA_INDEX_STATES] as $id => $state) {
      $instance
        ->setStateContext($id);
      $instance
        ->setState($state);
    }
    $instance
      ->setStateContext(NULL);
  }

  // Replay stored properties.
  if (isset($item_data[ProxyItemInterface::DATA_INDEX_PROPERTIES])) {
    foreach ($item_data[ProxyItemInterface::DATA_INDEX_PROPERTIES] as $id => $properties) {
      $instance
        ->setStateContext($id);
      foreach ($properties as $key => $value) {
        $instance
          ->setProperty($key, $value);
      }
    }
    $instance
      ->setStateContext(NULL);
  }
  return new ImmutableInvalidation($instance);
}