Skip to content

Commit

Permalink
[AsseticBundle] fix AsseticController - removed response service depe…
Browse files Browse the repository at this point in the history
…ndency
  • Loading branch information
marphi committed Feb 22, 2011
1 parent c63e1ac commit efb5617
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Expand Up @@ -26,14 +26,12 @@
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;
}
Expand All @@ -46,20 +44,22 @@ public function render($name)

$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)
Expand Down
Expand Up @@ -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>
Expand Down
Expand Up @@ -50,7 +50,6 @@ protected function setUp()
$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__);
Expand Down

0 comments on commit efb5617

Please sign in to comment.