/** * Install the default page templates. * * @param BundleInterface $bundle */ protected function installDefaultPageTemplates($bundle) { // Configuration templates $dirPath = sprintf('%s/Resources/config/pagetemplates/', $bundle->getPath()); $skeletonDir = sprintf('%s/Resources/config/pagetemplates/', GeneratorUtils::getFullSkeletonPath('/common')); // Only copy templates over when the folder does not exist yet... if (!$this->filesystem->exists($dirPath)) { $files = array('default-one-column.yml', 'default-two-column-left.yml', 'default-two-column-right.yml', 'default-three-column.yml'); foreach ($files as $file) { $this->filesystem->copy($skeletonDir . $file, $dirPath . $file, false); GeneratorUtils::replace("~~~BUNDLE~~~", $bundle->getName(), $dirPath . $file); } } // Twig templates $dirPath = sprintf('%s/Resources/views/Pages/Common/', $bundle->getPath()); $skeletonDir = sprintf('%s/Resources/views/Pages/Common/', GeneratorUtils::getFullSkeletonPath('/common')); if (!$this->filesystem->exists($dirPath)) { $files = array('one-column-pagetemplate.html.twig', 'two-column-left-pagetemplate.html.twig', 'two-column-right-pagetemplate.html.twig', 'three-column-pagetemplate.html.twig'); foreach ($files as $file) { $this->filesystem->copy($skeletonDir . $file, $dirPath . $file, false); } $this->filesystem->copy($skeletonDir . 'view.html.twig', $dirPath . 'view.html.twig', false); } $contents = file_get_contents($dirPath . 'view.html.twig'); if (strpos($contents, '{% extends ') === false) { GeneratorUtils::prepend("{% extends '" . $bundle->getName() . ":Layout:layout.html.twig' %}\n", $dirPath . 'view.html.twig'); } }
/** * Copy and modify default config files for the pagetemplate and pageparts. */ private function copyTemplateConfig() { $dirPath = $this->bundle->getPath(); $pagepartFile = $dirPath . '/Resources/config/pageparts/' . $this->template . '.yml'; $this->filesystem->copy($this->skeletonDir . '/Resources/config/pageparts/formpage.yml', $pagepartFile, false); GeneratorUtils::replace("~~~ENTITY~~~", $this->entity, $pagepartFile); $pagetemplateFile = $dirPath . '/Resources/config/pagetemplates/' . $this->template . '.yml'; $this->filesystem->copy($this->skeletonDir . '/Resources/config/pagetemplates/formpage.yml', $pagetemplateFile, false); GeneratorUtils::replace("~~~BUNDLE~~~", $this->bundle->getName(), $pagetemplateFile); GeneratorUtils::replace("~~~ENTITY~~~", $this->entity, $pagetemplateFile); }