diff options
| author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
| commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
| tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/symfony/cache/Messenger/EarlyExpirationMessage.php | |
| parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
| download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.gz AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.bz2 AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip | |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/symfony/cache/Messenger/EarlyExpirationMessage.php')
| -rw-r--r-- | vendor/symfony/cache/Messenger/EarlyExpirationMessage.php | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/vendor/symfony/cache/Messenger/EarlyExpirationMessage.php b/vendor/symfony/cache/Messenger/EarlyExpirationMessage.php new file mode 100644 index 0000000..6056eba --- /dev/null +++ b/vendor/symfony/cache/Messenger/EarlyExpirationMessage.php | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | * This file is part of the Symfony package. | ||
| 5 | * | ||
| 6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
| 7 | * | ||
| 8 | * For the full copyright and license information, please view the LICENSE | ||
| 9 | * file that was distributed with this source code. | ||
| 10 | */ | ||
| 11 | |||
| 12 | namespace Symfony\Component\Cache\Messenger; | ||
| 13 | |||
| 14 | use Symfony\Component\Cache\Adapter\AdapterInterface; | ||
| 15 | use Symfony\Component\Cache\CacheItem; | ||
| 16 | use Symfony\Component\DependencyInjection\ReverseContainer; | ||
| 17 | |||
| 18 | /** | ||
| 19 | * Conveys a cached value that needs to be computed. | ||
| 20 | */ | ||
| 21 | final class EarlyExpirationMessage | ||
| 22 | { | ||
| 23 | private CacheItem $item; | ||
| 24 | private string $pool; | ||
| 25 | private string|array $callback; | ||
| 26 | |||
| 27 | public static function create(ReverseContainer $reverseContainer, callable $callback, CacheItem $item, AdapterInterface $pool): ?self | ||
| 28 | { | ||
| 29 | try { | ||
| 30 | $item = clone $item; | ||
| 31 | $item->set(null); | ||
| 32 | } catch (\Exception) { | ||
| 33 | return null; | ||
| 34 | } | ||
| 35 | |||
| 36 | $pool = $reverseContainer->getId($pool); | ||
| 37 | |||
| 38 | if (\is_object($callback)) { | ||
| 39 | if (null === $id = $reverseContainer->getId($callback)) { | ||
| 40 | return null; | ||
| 41 | } | ||
| 42 | |||
| 43 | $callback = '@'.$id; | ||
| 44 | } elseif (!\is_array($callback)) { | ||
| 45 | $callback = (string) $callback; | ||
| 46 | } elseif (!\is_object($callback[0])) { | ||
| 47 | $callback = [(string) $callback[0], (string) $callback[1]]; | ||
| 48 | } else { | ||
| 49 | if (null === $id = $reverseContainer->getId($callback[0])) { | ||
| 50 | return null; | ||
| 51 | } | ||
| 52 | |||
| 53 | $callback = ['@'.$id, (string) $callback[1]]; | ||
| 54 | } | ||
| 55 | |||
| 56 | return new self($item, $pool, $callback); | ||
| 57 | } | ||
| 58 | |||
| 59 | public function getItem(): CacheItem | ||
| 60 | { | ||
| 61 | return $this->item; | ||
| 62 | } | ||
| 63 | |||
| 64 | public function getPool(): string | ||
| 65 | { | ||
| 66 | return $this->pool; | ||
| 67 | } | ||
| 68 | |||
| 69 | /** | ||
| 70 | * @return string|string[] | ||
| 71 | */ | ||
| 72 | public function getCallback(): string|array | ||
| 73 | { | ||
| 74 | return $this->callback; | ||
| 75 | } | ||
| 76 | |||
| 77 | public function findPool(ReverseContainer $reverseContainer): AdapterInterface | ||
| 78 | { | ||
| 79 | return $reverseContainer->getService($this->pool); | ||
| 80 | } | ||
| 81 | |||
| 82 | public function findCallback(ReverseContainer $reverseContainer): callable | ||
| 83 | { | ||
| 84 | if (\is_string($callback = $this->callback)) { | ||
| 85 | return '@' === $callback[0] ? $reverseContainer->getService(substr($callback, 1)) : $callback; | ||
| 86 | } | ||
| 87 | if ('@' === $callback[0][0]) { | ||
| 88 | $callback[0] = $reverseContainer->getService(substr($callback[0], 1)); | ||
| 89 | } | ||
| 90 | |||
| 91 | return $callback; | ||
| 92 | } | ||
| 93 | |||
| 94 | private function __construct(CacheItem $item, string $pool, string|array $callback) | ||
| 95 | { | ||
| 96 | $this->item = $item; | ||
| 97 | $this->pool = $pool; | ||
| 98 | $this->callback = $callback; | ||
| 99 | } | ||
| 100 | } | ||
