What is the idiomatic way to clear the entire cache in Twig from version 1.22.x?

Since the 1.22.0version Twig, the method is Twig_Environment::clearCacheFiles()deprecated. However, I did not find anywhere (either in the documentation, in the repo tickets, or here on SO) something that could replace this obsolete method.

So, what is the idiomatic (and not obsolete) way to clear all cache files now?

Removing these files using an implementation of our own function seems rather strange.

+4
source share
2 answers

Thus, there is no new idiomatic way to clear all cache files.
Twigproject developers leave this for library users on their own. Arguments:

, Twig (- opcache). , clear() , . , . , .

, @alain-tiemblo .

0

Twig, , . ( php, Twig), . , .

function clearCacheFiles($cacheLocation) {
  if (is_string($cacheLocation)) {
    foreach (new \RecursiveIteratorIterator(
        new \RecursiveDirectoryIterator($cacheLocation), 
        \RecursiveIteratorIterator::LEAVES_ONLY) as $file
    ) {
      if ($file->isFile()) {
        @unlink($file->getPathname());
      }
    }
  }
}

Twig/lib/Twig/Environment.php, , .

0

Source: https://habr.com/ru/post/1611623/


All Articles