Permalink
Browse files

various cosmetic tweaks

  • Loading branch information...
1 parent 7d2b5f5 commit 00fedac128dce758758b60ddeeb04c50ab746e4b @lsmith77 lsmith77 committed Dec 11, 2012
Showing with 21 additions and 10 deletions.
  1. +21 −10 EventListener/CacheControlListener.php
@@ -17,16 +17,29 @@
*/
class CacheControlListener
{
+ /**
+ * @var \Symfony\Component\Security\Core\SecurityContext
+ */
protected $securityContext;
+ /**
+ * @var array
+ */
protected $map = array();
/**
* supported headers from Response
*
* @var array
*/
- protected $supportedHeaders = array('etag' => true, 'last_modified' => true, 'max_age' => true, 's_maxage' => true, 'private' => true, 'public' => true);
+ protected $supportedHeaders = array(
+ 'etag' => true,
+ 'last_modified' => true,
+ 'max_age' => true,
+ 's_maxage' => true,
+ 'private' => true,
+ 'public' => true,
+ );
/**
* Constructor.
@@ -52,12 +65,10 @@ public function add(RequestMatcherInterface $requestMatcher, array $options = ar
*/
public function onKernelResponse(FilterResponseEvent $event)
{
- $response = $event->getResponse();
- $request = $event->getRequest();
-
- if ($options = $this->getOptions($request)) {
+ $options = $this->getOptions($event->getRequest());
+ if ($options) {
+ $response = $event->getResponse();
if (!empty($options['controls'])) {
-
$controls = array_intersect_key($options['controls'], $this->supportedHeaders);
$extraControls = array_diff_key($options['controls'], $controls);
@@ -66,7 +77,7 @@ public function onKernelResponse(FilterResponseEvent $event)
$response->setCache($this->prepareControls($controls));
}
- //set extra headers for varnish
+ //set extra headers, f.e. varnish specific headers
if (!empty($extraControls)) {
$this->setExtraControls($response, $extraControls);
}
@@ -137,7 +148,7 @@ protected function getOptions(Request $request)
}
}
- return null;
+ return array();
}
/**
@@ -146,10 +157,10 @@ protected function getOptions(Request $request)
* @param array $controls
* @return array
*/
- protected function prepareControls($controls)
+ protected function prepareControls(array $controls)
{
if (isset($controls['last_modified'])) {
- //this must be a DateTime, convert from the string in configuration
+ // this must be a DateTime, convert from the string in configuration
$controls['last_modified'] = new \DateTime($controls['last_modified']);
}

0 comments on commit 00fedac

Please sign in to comment.