-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a PHP 8 attribute to support configuration (#39)
This PR adds a `\Webfactory\Bundle\WfdMetaBundle\Caching\Attribute\Send304IfNotModified` attribute to replace the `\Webfactory\Bundle\WfdMetaBundle\Caching\Annotation\Send304IfNotModified` annotation class.
- Loading branch information
Showing
4 changed files
with
78 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/* | ||
* (c) webfactory GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Webfactory\Bundle\WfdMetaBundle\Caching\Attribute; | ||
|
||
use Attribute; | ||
use Exception; | ||
use Webfactory\Bundle\WfdMetaBundle\Helper\LastmodHelper; | ||
use Webfactory\Bundle\WfdMetaBundle\MetaQueryFactory; | ||
|
||
/** | ||
* @deprecated Use WebfactoryHttpCachingBundle and its LastModifiedDeterminators instead. If in a hurry, @see \Webfactory\Bundle\WfdMetaBundle\Caching\WfdMetaQueries for a quick conversion. | ||
*/ | ||
#[Attribute] | ||
class Send304IfNotModified | ||
{ | ||
protected $lastmodHelper; | ||
|
||
public function __construct(...$values) | ||
{ | ||
@trigger_error( | ||
'The Send304IfNotModified attribute is deprecated. Use WebfactoryHttpCachingBundle and its LastModifiedDeterminators instead. If in a hurry, @see \Webfactory\Bundle\WfdMetaBundle\Caching\WfdMetaQueries for a quick conversion.', | ||
\E_USER_DEPRECATED | ||
); | ||
|
||
$this->lastmodHelper = new LastmodHelper(); | ||
|
||
foreach ($values as $key => $value) { | ||
if (method_exists($this->lastmodHelper, $name = 'set'.ucfirst($key))) { | ||
$this->lastmodHelper->$name($value); | ||
} else { | ||
throw new Exception('Die Annotation '.static::class.' kann die Eigentschaft "'.$key.'" nicht setzen.'); | ||
} | ||
} | ||
} | ||
|
||
public function calculateLastModified(MetaQueryFactory $metaQueryFactory) | ||
{ | ||
return $this->lastmodHelper->calculateLastModified($metaQueryFactory); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters