/** * @param Root $root * * @return string */ private function calculeBasePath(Root $root) { $pathCollection = array(); foreach ($root->getFileCollection() as $file) { $pathCollection[] = $file->getName(); } return $this->getCommonPath($pathCollection) . '/'; }
/** * @param Root $root * @param string $target * @param string $templatePath */ public function render(Root $root, $target, $templatePath = false) { if ($templatePath === false) { $templatePath = __DIR__ . '/Template/'; } $twig = $this->twigCreator->createInstance($templatePath); foreach ($root->getFileCollection() as $file) { $this->renderFile($file, $twig, $target, $root->getBasePath()); } foreach ($root->getDirectoryCollection() as $directory) { $this->renderDirectory($directory, $root, $twig, $target); foreach ($directory->getFileCollection() as $file) { $this->renderFile($file, $twig, $target, $root->getBasePath()); } } $this->copyAssets($templatePath, $target); }