Bolt\Twig\FilesystemLoader::prependDir PHP Method

prependDir() public method

Prepends a directory where templates are stored.
public prependDir ( Bolt\Filesystem\Handler\DirectoryInterface $dir, string $namespace = self::MAIN_NAMESPACE )
$dir Bolt\Filesystem\Handler\DirectoryInterface
$namespace string
    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);
        }
    }