public function PathInvalidation::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 InvalidationBase::validateExpression
See also
\Drupal\purge\Annotation\PurgeInvalidation::$expression_required
\Drupal\purge\Annotation\PurgeInvalidation::$expression_can_be_empty
1 call to PathInvalidation::validateExpression()
- WildcardPathInvalidation::validateExpression in src/
Plugin/ Purge/ Invalidation/ WildcardPathInvalidation.php - Validate the expression given to the invalidation during instantiation.
1 method overrides PathInvalidation::validateExpression()
- WildcardPathInvalidation::validateExpression in src/
Plugin/ Purge/ Invalidation/ WildcardPathInvalidation.php - Validate the expression given to the invalidation during instantiation.
File
- src/
Plugin/ Purge/ Invalidation/ PathInvalidation.php, line 25
Class
- PathInvalidation
- Describes path based invalidation, e.g. "news/article-1".
Namespace
Drupal\purge\Plugin\Purge\InvalidationCode
public function validateExpression($wildcard_check = TRUE) {
parent::validateExpression();
if ($wildcard_check && strpos($this->expression, '*') !== FALSE) {
throw new InvalidExpressionException('Path invalidations should not contain asterisks.');
}
if ($wildcard_check && $this->expression === '*') {
throw new InvalidExpressionException('Path invalidations cannot be "*".');
}
if (strpos($this->expression, ' ') !== FALSE) {
throw new InvalidExpressionException('Path invalidations cannot contain spaces, use %20 instead.');
}
if (strpos($this->expression, '/') === 0) {
throw new InvalidExpressionException('Path invalidations cannot start with slashes.');
}
}