You are here

final class DoctrineCache in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Mapping/Cache/DoctrineCache.php \Symfony\Component\Validator\Mapping\Cache\DoctrineCache

Adapts a Doctrine cache to a CacheInterface.

@author Florian Voutzinos <florian@voutzinos.com>

Hierarchy

Expanded class hierarchy of DoctrineCache

1 file declares its use of DoctrineCache
DoctrineCacheTest.php in vendor/symfony/validator/Tests/Mapping/Cache/DoctrineCacheTest.php

File

vendor/symfony/validator/Mapping/Cache/DoctrineCache.php, line 22

Namespace

Symfony\Component\Validator\Mapping\Cache
View source
final class DoctrineCache implements CacheInterface {
  private $cache;

  /**
   * Creates a new Doctrine cache.
   *
   * @param Cache $cache The cache to adapt
   */
  public function __construct(Cache $cache) {
    $this->cache = $cache;
  }

  /**
   * Sets the cache to adapt.
   *
   * @param Cache $cache The cache to adapt
   */
  public function setCache(Cache $cache) {
    $this->cache = $cache;
  }

  /**
   * {@inheritdoc}
   */
  public function has($class) {
    return $this->cache
      ->contains($class);
  }

  /**
   * {@inheritdoc}
   */
  public function read($class) {
    return $this->cache
      ->fetch($class);
  }

  /**
   * {@inheritdoc}
   */
  public function write(ClassMetadata $metadata) {
    $this->cache
      ->save($metadata
      ->getClassName(), $metadata);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DoctrineCache::$cache private property
DoctrineCache::has public function Returns whether metadata for the given class exists in the cache. Overrides CacheInterface::has
DoctrineCache::read public function Returns the metadata for the given class from the cache. Overrides CacheInterface::read
DoctrineCache::setCache public function Sets the cache to adapt.
DoctrineCache::write public function Stores a class metadata in the cache. Overrides CacheInterface::write
DoctrineCache::__construct public function Creates a new Doctrine cache.