[AsseticBundle] fix AsseticController - removed response service dependency

This commit is contained in:
Marcin Sikon 2011-02-22 16:09:02 +01:00
parent c63e1ace81
commit efb561767b
3 changed files with 8 additions and 10 deletions

View File

@ -26,14 +26,12 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class AsseticController
{
protected $request;
protected $response;
protected $am;
protected $cache;
public function __construct(Request $request, Response $response, AssetManager $am, CacheInterface $cache)
public function __construct(Request $request, AssetManager $am, CacheInterface $cache)
{
$this->request = $request;
$this->response = $response;
$this->am = $am;
$this->cache = $cache;
}
@ -46,20 +44,22 @@ class AsseticController
$asset = $this->getAsset($name);
$response = new Response();
// validate if-modified-since
if (null !== $lastModified = $asset->getLastModified()) {
$date = new \DateTime();
$date->setTimestamp($lastModified);
$this->response->setLastModified($date);
$response->setLastModified($date);
if ($this->response->isNotModified($this->request)) {
return $this->response;
if ($response->isNotModified($this->request)) {
return $response;
}
}
$this->response->setContent($asset->dump());
$response->setContent($asset->dump());
return $this->response;
return $response;
}
protected function getAsset($name)

View File

@ -18,7 +18,6 @@
</service>
<service id="assetic.controller" class="%assetic.controller.class%" scope="prototype">
<argument type="service" id="request" />
<argument type="service" id="response" />
<argument type="service" id="assetic.asset_manager" />
<argument type="service" id="assetic.cache" />
</service>

View File

@ -50,7 +50,6 @@ class AsseticExtensionTest extends \PHPUnit_Framework_TestCase
$this->container = new ContainerBuilder();
$this->container->addScope(new Scope('request'));
$this->container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request');
$this->container->register('response', 'Symfony\\Component\\HttpFoundation\\Response')->setScope('prototype');
$this->container->register('twig', 'Twig_Environment');
$this->container->setParameter('kernel.debug', false);
$this->container->setParameter('kernel.root_dir', __DIR__);