protected function HeaderBag::parseCacheControl

Parses a Cache-Control HTTP header.

Parameters

string $header The value of the Cache-Control HTTP header:

Return value

array An array representing the attribute values

2 calls to HeaderBag::parseCacheControl()
HeaderBag::set in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php
Sets a header by name.
ResponseHeaderBag::set in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
@api

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php, line 313

Class

HeaderBag
HeaderBag is a container for HTTP headers.

Namespace

Symfony\Component\HttpFoundation

Code

protected function parseCacheControl($header) {
  $cacheControl = array();
  preg_match_all('#([a-zA-Z][a-zA-Z_-]*)\\s*(?:=(?:"([^"]*)"|([^ \\t",;]*)))?#', $header, $matches, PREG_SET_ORDER);
  foreach ($matches as $match) {
    $cacheControl[strtolower($match[1])] = isset($match[2]) && $match[2] ? $match[2] : (isset($match[3]) ? $match[3] : true);
  }
  return $cacheControl;
}