Updating Media dependent modules to versions compatible with core Media.
[yaffs-website] / vendor / symfony / validator / Mapping / Cache / DoctrineCache.php
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\Validator\Mapping\Cache;
13
14 use Doctrine\Common\Cache\Cache;
15 use Symfony\Component\Validator\Mapping\ClassMetadata;
16
17 /**
18  * Adapts a Doctrine cache to a CacheInterface.
19  *
20  * @author Florian Voutzinos <florian@voutzinos.com>
21  */
22 final class DoctrineCache implements CacheInterface
23 {
24     private $cache;
25
26     public function __construct(Cache $cache)
27     {
28         $this->cache = $cache;
29     }
30
31     public function setCache(Cache $cache)
32     {
33         $this->cache = $cache;
34     }
35
36     /**
37      * {@inheritdoc}
38      */
39     public function has($class)
40     {
41         return $this->cache->contains($class);
42     }
43
44     /**
45      * {@inheritdoc}
46      */
47     public function read($class)
48     {
49         return $this->cache->fetch($class);
50     }
51
52     /**
53      * {@inheritdoc}
54      */
55     public function write(ClassMetadata $metadata)
56     {
57         $this->cache->save($metadata->getClassName(), $metadata);
58     }
59 }