public function testUseModifiedSince() { $value = $this->object->getUseModifiedSince(); $this->assertTrue($value); $expected = false; $this->object->setUseModifiedSince($expected); $value = $this->object->getUseModifiedSince(); $this->assertFalse($value); }
public function onFinish(MvcEvent $e) { /** @var $response Response */ $response = $e->getResponse(); if (!$response instanceof Response) { return; } $headers = $response->getHeaders(); /** @var $lastModified LastModified */ $lastModified = $headers->get('Last-Modified'); if (!$lastModified instanceof LastModified) { $lastModified = new LastModified(); $headers->addHeader($lastModified); } /** @var $cacheControl CacheControl */ $cacheControl = $headers->get('Cache-Control'); if ($cacheControl instanceof CacheControl) { // Nope, you send it... i won't modified it. return; } $cacheControl = new CacheControl(); $headers->addHeader($cacheControl); if (null !== ($value = $this->config->getMaxAge())) { $cacheControl->addDirective('max-age', $value); } if (null !== ($value = $this->config->getSMaxAge())) { $cacheControl->addDirective('s-maxage', $value); } if ($this->config->istMustRevalidate()) { $cacheControl->addDirective('must-revalidate'); } }
public function onRoute(MvcEvent $e) { $routeMatch = $e->getRouteMatch(); if (!$routeMatch) { return; } $config = $e->getApplication()->getServiceManager()->get('Config'); if (!isset($config['router'], $config['router']['routes'])) { return; } $config = (array) $config['router']['routes']; $routeName = $routeMatch->getMatchedRouteName(); if (false !== strpos($routeName, self::CHILD_ROUTE_TOKEN)) { $part = strtok($routeName, self::CHILD_ROUTE_TOKEN); while ($part !== false) { if (isset($config[$part])) { $config = (array) $config[$part]; } else { if (isset($config['child_routes'], $config['child_routes'][$part])) { $config = (array) $config['child_routes'][$part]; } else { return; } } $part = strtok(self::CHILD_ROUTE_TOKEN); } } else { if (isset($config[$routeName])) { $config = (array) $config[$routeName]; } else { return; } } if (!isset($config[Config::CONFIG_NAMESPACE])) { return; } $config = $config[Config::CONFIG_NAMESPACE]; $this->config->merge($config); }