/** * {@inheritdoc} */ public function gc($maxlifetime) { if (!$this->directory->exists()) { return; } $files = $this->directory->find()->files()->ignoreDotFiles(false)->date("< now - {$maxlifetime} seconds"); foreach ($files as $file) { /** @var $file FileInterface */ $file->delete(); } }
/** * Helper function for doFlush(). * * @param DirectoryInterface $directory */ private function flushDirectory(DirectoryInterface $directory) { if (!$directory->exists()) { return; } $files = $directory->find()->ignoreDotFiles()->ignoreVCS(); /** @var HandlerInterface $file */ foreach ($files as $file) { try { $file->delete(); } catch (IOException $e) { } } }
/** * Prepends a directory where templates are stored. * * @param DirectoryInterface $dir * @param string $namespace * * @throws LoaderError */ public function prependDir(DirectoryInterface $dir, $namespace = self::MAIN_NAMESPACE) { // invalidate the cache $this->cache = $this->errorCache = []; if (!$dir->exists()) { throw new LoaderError(sprintf('The "%s" directory does not exist.', $dir->getFullPath())); } if (!$dir->isDir()) { throw new LoaderError(sprintf('The path "%s" is not a directory.', $dir->getFullPath())); } if (!isset($this->paths[$namespace])) { $this->paths[$namespace][] = $dir; } else { array_unshift($this->paths[$namespace], $dir); } }