/** * @param Bundle $bundle The bundle * @param array $parameters The template parameters * @param string $rootDir The root directory * @param OutputInterface $output */ public function generateTemplates(Bundle $bundle, array $parameters, $rootDir, OutputInterface $output) { $dirPath = $bundle->getPath(); $fullSkeletonDir = $this->skeletonDir . '/Resources/views'; $this->filesystem->copy(__DIR__ . '/../Resources/SensioGeneratorBundle/skeleton' . $fullSkeletonDir . '/Pages/Search/SearchPage/view.html.twig', $dirPath . '/Resources/views/Pages/Search/SearchPage/view.html.twig', true); GeneratorUtils::prepend("{% extends '" . $bundle->getName() . ":Page:layout.html.twig' %}\n", $dirPath . '/Resources/views/Pages/Search/SearchPage/view.html.twig'); $output->writeln('Generating Twig Templates : <info>OK</info>'); }
/** * @param Bundle $bundle The bundle * @param string $entity The name of the entity * @param array $parameters The template parameters * @param OutputInterface $output */ public function generateTemplates(Bundle $bundle, $entity, array $parameters, OutputInterface $output) { $dirPath = sprintf("%s/Resources/views", $bundle->getPath()); $skeletonDir = sprintf("%s/Resources/views", $this->skeletonDir); $fullSkeletonDir = sprintf("%s/Resources/views", $this->fullSkeletonDir); $this->filesystem->copy($fullSkeletonDir . '/OverviewPage/view.html.twig', $dirPath . '/Pages/' . $entity . 'OverviewPage/view.html.twig', true); GeneratorUtils::prepend("{% extends '" . $bundle->getName() . ":Layout:layout.html.twig' %}\n", $dirPath . '/Pages/' . $entity . 'OverviewPage/view.html.twig'); $this->filesystem->copy($fullSkeletonDir . '/OverviewPage/pagetemplate.html.twig', $dirPath . '/Pages/' . $entity . 'OverviewPage/pagetemplate.html.twig', true); $this->filesystem->copy($fullSkeletonDir . '/Page/view.html.twig', $dirPath . '/Pages/' . $entity . 'Page/view.html.twig', true); GeneratorUtils::prepend("{% extends '" . $bundle->getName() . ":Layout:layout.html.twig' %}\n", $dirPath . '/Pages/' . $entity . 'Page/view.html.twig'); $this->filesystem->copy($fullSkeletonDir . '/Page/pagetemplate.html.twig', $dirPath . '/Pages/' . $entity . 'Page/pagetemplate.html.twig', true); $this->renderFile($skeletonDir . '/PageAdminList/list.html.twig', $dirPath . '/AdminList/' . '/' . $entity . 'PageAdminList/list.html.twig', $parameters); $output->writeln('Generating twig templates : <info>OK</info>'); }
/** * 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 formPage templates */ private function copyTemplates() { $dirPath = $this->bundle->getPath(); $this->filesystem->copy($this->skeletonDir . '/Resources/views/Pages/FormPage/view.html.twig', $dirPath . '/Resources/views/Pages/' . $this->entity . '/view.html.twig', true); $this->filesystem->copy($this->skeletonDir . '/Resources/views/Pages/FormPage/pagetemplate.html.twig', $dirPath . '/Resources/views/Pages/' . $this->entity . '/pagetemplate.html.twig', true); GeneratorUtils::replace("~~~BUNDLE~~~", $this->bundle->getName(), $dirPath . '/Resources/views/Pages/' . $this->entity . '/pagetemplate.html.twig'); GeneratorUtils::prepend("{% extends '" . $this->bundle->getName() . ":Page:layout.html.twig' %}\n", $dirPath . '/Resources/views/Pages/' . $this->entity . '/view.html.twig'); }