public function PageNotFoundRequest::evaluate in Block In Page Not Found 8.3
Same name and namespace in other branches
- 8.4 src/Plugin/Condition/PageNotFoundRequest.php \Drupal\block_in_page_not_found\Plugin\Condition\PageNotFoundRequest::evaluate()
Evaluates the condition and returns TRUE or FALSE accordingly.
Return value
bool TRUE if the condition has been met, FALSE otherwise.
Overrides ConditionInterface::evaluate
File
- src/
Plugin/ Condition/ PageNotFoundRequest.php, line 96
Class
- PageNotFoundRequest
- Class PageNotFoundRequest.
Namespace
Drupal\block_in_page_not_found\Plugin\ConditionCode
public function evaluate() {
// Get the configuration of the page not found.
$page_not_found_checked = $this->configuration['page_not_found'];
// If show "in page not found" is not checked
// or "show in page not found" was passed from checked to unchecked.
if (!$page_not_found_checked || $page_not_found_checked == 0) {
return FALSE;
}
// If show "in page not found" is not checked.
if ($page_not_found_checked == 1) {
$status = $this->requestStack
->getCurrentRequest()->attributes
->get('exception');
if ($status && $status
->getStatusCode() == 404) {
return TRUE;
}
else {
return FALSE;
}
}
}