You are here

public function Twig_Environment::setCache in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/lib/Twig/Environment.php \Twig_Environment::setCache()

Sets the current cache implementation.

Parameters

Twig_CacheInterface|string|false $cache A Twig_CacheInterface implementation,: an absolute path to the compiled templates, or false to disable cache

1 call to Twig_Environment::setCache()
Twig_Environment::__construct in vendor/twig/twig/lib/Twig/Environment.php
Constructor.

File

vendor/twig/twig/lib/Twig/Environment.php, line 259

Class

Twig_Environment
Stores the Twig configuration.

Code

public function setCache($cache) {
  if (is_string($cache)) {
    $this->originalCache = $cache;
    $this->cache = new Twig_Cache_Filesystem($cache);
  }
  elseif (false === $cache) {
    $this->originalCache = $cache;
    $this->cache = new Twig_Cache_Null();
  }
  elseif (null === $cache) {
    @trigger_error('Using "null" as the cache strategy is deprecated and will be removed in Twig 2.0.', E_USER_DEPRECATED);
    $this->originalCache = false;
    $this->cache = new Twig_Cache_Null();
  }
  elseif ($cache instanceof Twig_CacheInterface) {
    $this->originalCache = $this->cache = $cache;
  }
  else {
    throw new LogicException(sprintf('Cache can only be a string, false, or a Twig_CacheInterface implementation.'));
  }
}