You are here

protected function AliasController::addResponseHeaders in Mini site 8

Add headers to the response object.

Parameters

\Symfony\Component\HttpFoundation\Response $response: The response object.

\Drupal\minisite\Asset $asset: The loaded asset to be used for contextual data.

1 call to AliasController::addResponseHeaders()
AliasController::deliverAsset in src/Controller/AliasController.php
Request callback to deliver a single minisite asset.

File

src/Controller/AliasController.php, line 61

Class

AliasController
Class AliasController.

Namespace

Drupal\minisite\Controller

Code

protected function addResponseHeaders(Response $response, Asset $asset) {

  // @todo: Review and implement better caching strategy + add tests.
  $response
    ->setPublic();
  $max_age = $asset
    ->getCacheMaxAge();
  $response
    ->setMaxAge($max_age);
  $expires = new \DateTime();
  $expires
    ->setTimestamp(\Drupal::time()
    ->getRequestTime() + $max_age);
  $response
    ->setExpires($expires);
  $response->headers
    ->add($asset
    ->getHeaders());
}