protected function HttpResponseHeadersTestCase::createHeaderRule in HTTP Response Headers 7
Helper to create new header rule.
Parameters
string $machine_name: A string rule ID.
string $name: A string name.
string $header: A string header.
mixed $header_value: Header value
array $visibility_options: An array of visibility options.
Return value
string A string rule ID created.
3 calls to HttpResponseHeadersTestCase::createHeaderRule()
- HttpResponseHeadersTestCase::testHeaderRuleHelpers in ./
http_response_headers.test - Test header rule helpers that changes the user input.
- HttpResponseHeadersTestCase::testHeaderRuleVisibility in ./
http_response_headers.test - Test header rule visibility.
- HttpResponseHeadersTestCase::testHeaderRuleVisibilityListedEmpty in ./
http_response_headers.test - Test header rule with empty "pages".
File
- ./
http_response_headers.test, line 184 - Tests for http_response_headers.module.
Class
- HttpResponseHeadersTestCase
- @file Tests for http_response_headers.module.
Code
protected function createHeaderRule($machine_name, $name, $header, $header_value, $visibility_options = array()) {
$header_rule = new HttpResponseHeadersRule();
$header_rule->description = $name;
$header_rule->machine_name = $machine_name;
$header_rule->header = $header;
$header_rule->header_value = $header_value;
$header_rule->visibility = isset($visibility_options['visibility']) ? $visibility_options['visibility'] : HTTP_RESPONSE_HEADERS_VISIBILITY_NOTLISTED;
if (isset($visibility_options['pages'])) {
$header_rule->pages = $visibility_options['pages'];
}
if (isset($visibility_options['types'])) {
$header_rule->types = $visibility_options['types'];
}
if (isset($visibility_options['roles'])) {
$header_rule->roles = $visibility_options['roles'];
}
http_response_headers_rule_save($header_rule);
return $machine_name;
}