1 http_response_code_layout_access.inc public HttpResponseCodeLayoutAccess::checkAccess()

Checks for access based on the available context.

Return value

boolean: The result of the access check.

Overrides LayoutAccess::checkAccess

File

core/modules/layout/plugins/access/http_response_code_layout_access.inc, line 53
Plugin to provide access control by the server HTTP response code.

Class

HttpResponseCodeLayoutAccess
@file Plugin to provide access control by the server HTTP response code.

Code

public function checkAccess() {
  $allowed_status_codes = array_filter($this->settings['http_response_codes']);

  $http_response_header = backdrop_get_http_header('Status');
  if ($http_response_header) {
    $current_status_code = substr($http_response_header, 0, 3);
  }
  // Response header might not be set, which indicates a normal page load.
  else {
    $current_status_code = '200';
  }

  $access = in_array($current_status_code, $allowed_status_codes);

  return $this->settings['negate'] ? !$access : $access;
}