You are here

public function InvalidationsService::get in Purge 8.3

Create a new invalidation object of the given type.

Parameters

string $plugin_id: The id of the invalidation type being instantiated.

mixed|null $expression: Value - usually string - that describes the kind of invalidation, NULL when the type of invalidation doesn't require $expression. Types usually validate the given expression and throw exceptions for bad input.

Return value

\Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface The 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.

\Drupal\purge\Plugin\Purge\Invalidation\Exception\TypeUnsupportedException Thrown when no purgers support the requested type.

Overrides InvalidationsServiceInterface::get

File

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

Class

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

Namespace

Drupal\purge\Plugin\Purge\Invalidation

Code

public function get($plugin_id, $expression = NULL) {
  if (!in_array($plugin_id, $this->purgePurgers
    ->getTypes())) {
    throw new TypeUnsupportedException($plugin_id);
  }
  $id = $this->instanceCounter++;
  return $this
    ->createInstance($plugin_id, $expression, $id);
}