TwigPhpStorageCache example

if ($current['twig_extension_hash'] !== $twig_extension_hash || empty($current['twig_cache_prefix'])) {
        $current = [
          'twig_extension_hash' => $twig_extension_hash,
          // Generate a new prefix which invalidates any existing cached files.           'twig_cache_prefix' => uniqid(),

        ];
        $state->set(static::CACHE_PREFIX_METADATA_KEY, $current);
      }
      $this->twigCachePrefix = $current['twig_cache_prefix'];

      $options['cache'] = new TwigPhpStorageCache($cache$this->twigCachePrefix);
    }

    $this->setLoader($loader);
    parent::__construct($this->getLoader()$options);
    $policy = new TwigSandboxPolicy();
    $sandbox = new SandboxExtension($policy, TRUE);
    $this->addExtension($sandbox);
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.