| 1 | <?php |
||
| 21 | class SymfonyValidatorBridge implements CacheInterface |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * @type CacheItemPoolInterface |
||
| 25 | */ |
||
| 26 | private $pool; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * DoctrineCacheBridge constructor. |
||
| 30 | * |
||
| 31 | * @param CacheItemPoolInterface $cachePool |
||
| 32 | */ |
||
| 33 | public function __construct(CacheItemPoolInterface $cachePool) |
||
| 34 | { |
||
| 35 | $this->pool = $cachePool; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * {@inheritdoc} |
||
| 40 | */ |
||
| 41 | public function has($class) |
||
| 42 | { |
||
| 43 | return $this->pool->hasItem($this->normalizeKey($class)); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * {@inheritdoc} |
||
| 48 | */ |
||
| 49 | public function read($class) |
||
| 50 | { |
||
| 51 | $item = $this->pool->getItem($this->normalizeKey($class)); |
||
| 52 | |||
| 53 | if (!$item->isHit()) { |
||
| 54 | return false; |
||
| 55 | } |
||
| 56 | |||
| 57 | return $item->get(); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * {@inheritdoc} |
||
| 62 | */ |
||
| 63 | public function write(ClassMetadata $metadata) |
||
| 64 | { |
||
| 65 | $item = $this->pool->getItem($this->normalizeKey($metadata->getClassName())); |
||
| 66 | $item->set($metadata); |
||
| 67 | $this->pool->save($item); |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @param string $key |
||
| 72 | * |
||
| 73 | * @return string |
||
| 74 | */ |
||
| 75 | private function normalizeKey($key) |
||
| 79 | } |
||
| 80 |