Skip to content

Commit

Permalink
[FrameworkBundle] made the Esi and Store instances configurable in Ht…
Browse files Browse the repository at this point in the history
…tpCache base class
  • Loading branch information
fabpot committed Apr 13, 2012
1 parent 0956be9 commit 70df8d3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php
Expand Up @@ -25,6 +25,9 @@
*/
abstract class HttpCache extends BaseHttpCache
{
protected $cacheDir;
protected $kernel;

/**
* Constructor.
*
Expand All @@ -33,10 +36,10 @@ abstract class HttpCache extends BaseHttpCache
*/
public function __construct(HttpKernelInterface $kernel, $cacheDir = null)
{
$store = new Store($cacheDir ?: $kernel->getCacheDir().'/http_cache');
$esi = new Esi();
$this->kernel = $kernel;
$this->cacheDir = $cacheDir;

parent::__construct($kernel, $store, $esi, array_merge(array('debug' => $kernel->isDebug()), $this->getOptions()));
parent::__construct($kernel, $this->getStore(), $this->getEsi(), array_merge(array('debug' => $kernel->isDebug()), $this->getOptions()));
}

/**
Expand Down Expand Up @@ -66,4 +69,14 @@ protected function getOptions()
{
return array();
}

protected function getEsi()
{
return new Esi();
}

protected function getStore()
{
return new Store($this->cacheDir ?: $this->kernel->getCacheDir().'/http_cache');
}
}

2 comments on commit 70df8d3

@fabpot
Copy link
Member Author

@fabpot fabpot commented on 70df8d3 Apr 13, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an abstract class. The concrete class is generated under the app/ directory. So, overriding the ESI class is just a matter of overriding the getEsi() method.

@fabpot
Copy link
Member Author

@fabpot fabpot commented on 70df8d3 Apr 13, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed now

Please sign in to comment.