function ResponseStatus::evaluate
Overrides ConditionInterface::evaluate
File
-
core/
modules/ system/ src/ Plugin/ Condition/ ResponseStatus.php, line 104
Class
- ResponseStatus
- Provides a 'Response status' condition.
Namespace
Drupal\system\Plugin\ConditionCode
public function evaluate() : bool {
$allowed_codes = $this->configuration['status_codes'];
if (empty($allowed_codes)) {
return TRUE;
}
$exception = $this->requestStack
->getCurrentRequest()->attributes
->get('exception');
if ($exception) {
return $exception instanceof HttpExceptionInterface && in_array($exception->getStatusCode(), $allowed_codes, TRUE);
}
return in_array(Response::HTTP_OK, $allowed_codes, TRUE);
}