Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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