Ejemplo n.º 1
0
 /**
  * @todo Memory?
  * @param ViewsConfig        $config
  * @param FilesInterface     $files
  * @param ContainerInterface $container
  */
 public function __construct(ViewsConfig $config, FilesInterface $files, ContainerInterface $container)
 {
     $this->config = $config;
     $this->files = $files;
     $this->container = $container;
     $this->loader = new ViewLoader($config->getNamespaces(), $files);
     $this->environment = new ViewEnvironment($config->environmentDependencies(), $config->cacheEnabled(), $config->cacheDirectory(), $container);
 }
Ejemplo n.º 2
0
 /**
  * @param ViewsConfig    $config
  * @param FilesInterface $files
  */
 public function perform(ViewsConfig $config, FilesInterface $files)
 {
     if (!$files->exists($config->cacheDirectory())) {
         $this->writeln("Cache directory is missing, no cache to be cleaned.");
         return;
     }
     $this->isVerbosity() && $this->writeln("<info>Clearing view cache:</info>");
     $cachedViews = $files->getFiles($config->cacheDirectory());
     foreach ($cachedViews as $filename) {
         $files->delete($filename);
         if ($this->isVerbosity()) {
             $this->writeln($files->relativePath($filename, $config->cacheDirectory()));
         }
     }
     if (empty($filename) && $this->isVerbosity()) {
         $this->writeln("No cached views were found.");
     }
     $this->writeln("<info>View cache has been cleared.</info>");
 }