Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Environment.php

function Environment::setCache

Sets the current cache implementation.

Parameters

CacheInterface|string|false $cache A Twig\Cache\CacheInterface implementation,: an absolute path to the compiled templates, or false to disable cache

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

File

vendor/twig/twig/src/Environment.php, line 271

Class

Environment
Stores the Twig configuration and renders templates.

Namespace

Twig

Code

public function setCache($cache) {
    if (\is_string($cache)) {
        $this->originalCache = $cache;
        $this->cache = new FilesystemCache($cache, $this->autoReload ? FilesystemCache::FORCE_BYTECODE_INVALIDATION : 0);
    }
    elseif (false === $cache) {
        $this->originalCache = $cache;
        $this->cache = new NullCache();
    }
    elseif ($cache instanceof CacheInterface) {
        $this->originalCache = $this->cache = $cache;
    }
    else {
        throw new \LogicException('Cache can only be a string, false, or a \\Twig\\Cache\\CacheInterface implementation.');
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal