You are here

public function WildcardUrlInvalidation::validateExpression in Purge 8.3

Validate the expression given to the invalidation during instantiation.

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 UrlInvalidation::validateExpression

See also

\Drupal\purge\Annotation\PurgeInvalidation::$expression_required

\Drupal\purge\Annotation\PurgeInvalidation::$expression_can_be_empty

File

src/Plugin/Purge/Invalidation/WildcardUrlInvalidation.php, line 24

Class

WildcardUrlInvalidation
Describes wildcard URL based invalidation, e.g. "http://site.com/node/*".

Namespace

Drupal\purge\Plugin\Purge\Invalidation

Code

public function validateExpression($wildcard_check = TRUE) {
  $url = parent::validateExpression(FALSE);
  if (strpos($url, '*') === FALSE) {
    throw new InvalidExpressionException('Wildcard invalidations should contain an asterisk.');
  }
}