You are here

function http_response_headers_rule_save in HTTP Response Headers 7

Save a single header rule to the database.

Parameters

HttpResponseHeadersRule $rule: The rule object.

Return value

bool TRUE or FALSE flag of save operation.

3 calls to http_response_headers_rule_save()
drush_http_response_headers_http_header_add in ./http_response_headers.drush.inc
Sets header rule.
drush_http_response_headers_http_header_set in ./http_response_headers.drush.inc
Sets header rule.
HttpResponseHeadersTestCase::createHeaderRule in ./http_response_headers.test
Helper to create new header rule.
1 string reference to 'http_response_headers_rule_save'
http_response_headers_schema in ./http_response_headers.install
Implements hook_schema().

File

./http_response_headers.module, line 182
Contains HTTP response headers.

Code

function http_response_headers_rule_save(HttpResponseHeadersRule $rule) {
  db_merge('http_response_headers')
    ->key(array(
    'machine_name' => $rule
      ->getMachineName(),
  ))
    ->fields(array(
    'description' => $rule
      ->getDescription(),
    'header' => $rule
      ->getHeader(),
    'header_value' => $rule
      ->getHeaderValue(),
    'pages' => $rule
      ->getPages(),
    'visibility' => $rule
      ->getVisibility(),
    'types' => $rule
      ->getTypes(),
    'roles' => $rule
      ->getRoles(),
    // Serialize the whole object into data column, this way, any classes that
    // subclass the base object will have an opportunity to save their data
    // too!
    'data' => serialize($rule),
  ))
    ->execute();

  // Clear the header rules cache.
  http_response_headers_cache_reset();
  return TRUE;
}