You are here

protected function TwitterWidgetSubscriber::setExpiresCacheLifetime in Twitter Profile Widget 8

Same name and namespace in other branches
  1. 8.2 src/EventSubscriber/TwitterWidgetSubscriber.php \Drupal\twitter_profile_widget\EventSubscriber\TwitterWidgetSubscriber::setExpiresCacheLifetime()
  2. 3.x src/EventSubscriber/TwitterWidgetSubscriber.php \Drupal\twitter_profile_widget\EventSubscriber\TwitterWidgetSubscriber::setExpiresCacheLifetime()

Set cache lifetime to cache.page.max_age.

This overrides the default logic provided by Internal Page Cache.

Parameters

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

1 call to TwitterWidgetSubscriber::setExpiresCacheLifetime()
TwitterWidgetSubscriber::onRespond in src/EventSubscriber/TwitterWidgetSubscriber.php
Sets extra headers on successful responses.

File

src/EventSubscriber/TwitterWidgetSubscriber.php, line 126

Class

TwitterWidgetSubscriber
Class TwitterWidgetSubscriber.

Namespace

Drupal\twitter_profile_widget\EventSubscriber

Code

protected function setExpiresCacheLifetime(Response $response) {
  $max_age = $this->config
    ->get('cache.page.max_age');
  $response
    ->setExpires(\DateTime::createFromFormat('U', time() + $max_age));
}