You are here

public function PageNotFoundRequest::evaluate in Block In Page Not Found 8.4

Same name and namespace in other branches
  1. 8.3 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 98

Class

PageNotFoundRequest
Provides a 'Page not found' condition.

Namespace

Drupal\block_in_page_not_found\Plugin\Condition

Code

public function evaluate() {
  $page_not_found_checked = $this->configuration['page_not_found'];
  if ($page_not_found_checked == 1) {
    $status = $this->requestStack
      ->getCurrentRequest()->attributes
      ->get('exception');
    if ($status && $status
      ->getStatusCode() == 404) {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }
  else {
    return TRUE;
  }
}