You are here

function context_error_context_condition_error::execute in Context error 7

Same name and namespace in other branches
  1. 6 plugins/context_error_context_conditions.inc \context_error_context_condition_error::execute()

Execute.

File

plugins/context_error_context_conditions.inc, line 88
Context condition plugin to provide a trigger for 404 and 403 error pages.

Class

context_error_context_condition_error
Expose the 404 error page as the context condition.

Code

function execute() {
  if ($this
    ->condition_used()) {
    $headers = drupal_get_http_header();
    foreach ($this
      ->get_contexts() as $context) {
      $errors = $this
        ->fetch_from_context($context, 'values');
      if (isset($headers['status']) && $this
        ->is_error($headers['status'])) {
        foreach ($errors as $error) {
          if (isset($this->known_errors[$error]) && $this->known_errors[$error] == $headers['status']) {
            $this
              ->condition_met($context);
          }
        }
      }
      else {
        if (array_key_exists(CONTEXT_ERROR_NOT_ERROR, $this
          ->fetch_from_context($context, 'values'))) {
          $this
            ->condition_met($context);
        }
      }
    }
  }
}