Skip to content

Commit

Permalink
Read attributes as provided by the event object, and pass on attribut…
Browse files Browse the repository at this point in the history
…es to other event handlers
  • Loading branch information
mpdude committed Oct 28, 2024
1 parent 60bfdaf commit 6964685
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"symfony/filesystem": "^5.4|^6.4|^7.0",
"symfony/finder": "^5.4|^6.4|^7.0",
"symfony/http-foundation": "^5.4|^6.4|^7.0",
"symfony/http-kernel": "^5.4|^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/lock": "^5.4|^6.4|^7.0",
"symfony/twig-bundle": "^5.4|^6.4|^7.0",
"twig/twig": "^2.0|^3.0"
Expand Down
12 changes: 5 additions & 7 deletions src/Caching/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,19 @@ public function __construct(MetaQueryFactory $metaQueryFactory, $debug)

public function onKernelController(ControllerEvent $event)
{
$controller = $event->getController();
$request = $event->getRequest();

$attribute = $this->findAttribute($controller);
$attributes = $event->getAttributes(Send304IfNotModified::class);

if (!$attribute) {
if (!$attributes) {
return;
}

$lastTouched = $attribute->calculateLastModified($this->metaQueryFactory);
$lastTouched = $attributes[0]->calculateLastModified($this->metaQueryFactory);

if (!$lastTouched) {
return;
}

$request = $event->getRequest();
$this->lastTouchedResults[$request] = $lastTouched;

/*
Expand All @@ -73,7 +71,7 @@ public function onKernelController(ControllerEvent $event)
if ($response->isNotModified($request)) {
$event->setController(function () use ($response) {
return $response;
});
}, $event->getAttributes());
}
}

Expand Down

0 comments on commit 6964685

Please sign in to comment.