public function __construct($path, $root, TemplateRepository $repository)
{
$rootpath = "{$root}/{$path}";
$realpath = realpath($rootpath);
if (!$realpath) {
throw new \InvalidArgumentException($rootpath);
}
$this->root = realpath($root);
$this->path = str_replace("{$this->root}/", '', $realpath);
$this->files = array_merge(glob("{$realpath}/*", GLOB_ONLYDIR), glob("{$realpath}/*.*"));
// get sorted dirs + sorted files
$this->repository = $repository;
}