diff --git a/src/Caching/Attribute/Send304IfNotModified.php b/src/Caching/Attribute/Send304IfNotModified.php index 4c4c21e..2d7e960 100644 --- a/src/Caching/Attribute/Send304IfNotModified.php +++ b/src/Caching/Attribute/Send304IfNotModified.php @@ -10,6 +10,7 @@ use Attribute; use Exception; +use InvalidArgumentException; use Webfactory\Bundle\WfdMetaBundle\Helper\LastmodHelper; use Webfactory\Bundle\WfdMetaBundle\MetaQueryFactory; @@ -28,6 +29,10 @@ public function __construct(...$values) \E_USER_DEPRECATED ); + if (!$values) { + throw new InvalidArgumentException(sprintf('The %s attribute needs at least one criterion', __CLASS__)); + } + $this->lastmodHelper = new LastmodHelper(); foreach ($values as $key => $value) { diff --git a/src/Caching/EventListener.php b/src/Caching/EventListener.php index d06f907..1785642 100644 --- a/src/Caching/EventListener.php +++ b/src/Caching/EventListener.php @@ -109,7 +109,7 @@ protected function findAttribute($callback): ?Attribute\Send304IfNotModified $attributes = $method->getAttributes(\Webfactory\Bundle\WfdMetaBundle\Caching\Attribute\Send304IfNotModified::class); if ($attributes) { - return $attributes[0]; + return $attributes[0]->newInstance(); } }