Ejemplo n.º 1
0
 protected function renderTargetBundleFile($renderTemplate, $variables, $outputFolder = '', $outputFileName = null, $overwrite = false, $type = null, $templatingEnine = self::TEMPLATING_ENGINE_PHP)
 {
     $ext = pathinfo($renderTemplate, PATHINFO_EXTENSION);
     if (!$type) {
         $type = $ext;
     }
     if (!$ext) {
         $renderTemplate .= ".{$type}";
     }
     if (!$outputFileName) {
         $outputFileName = "{$renderTemplate}";
     }
     $templatePath = "StudioArtlanSyngBundle:Skeleton:{$renderTemplate}.{$templatingEnine}";
     $outputContent = $this->getContainer()->get('templating')->render($templatePath, $variables);
     $outputFilePath = $this->getTargetBundleFilePath($outputFolder, $outputFileName);
     $this->output->writeln("Generating file: {$templatePath} -> {$outputFilePath}");
     FileUtils::createFile($outputFilePath, $outputContent, $overwrite);
 }
Ejemplo n.º 2
0
 private function parseRoutes()
 {
     $router = $this->getContainer()->get('router');
     $collection = $router->getRouteCollection();
     $allRoutes = $collection->all();
     $routes = array();
     foreach ($allRoutes as $routeIdentifier => $route) {
         if (strpos($routeIdentifier, '_') === 0) {
             continue;
         }
         $pattern = $route->getPattern();
         $templateName = preg_replace('/{[^}]*}/', '', $pattern);
         $templateName = rtrim($templateName, '/');
         if (!$templateName) {
             $templateName = 'index';
         }
         $templateName = FileUtils::concatPath(self::SUBFOLDER_PARTIALS, self::TEMPLATES_FOLDER, $templateName . self::TEMPLATES_EXTENSION);
         $templateFile = self::getTargetBundleFilePath(self::SUBFOLDER_APP, $templateName);
         $this->output->writeln("Creating template: {$templateName} -> {$templateFile}");
         FileUtils::createFile($templateFile);
         $routes[$routeIdentifier] = array('url' => $pattern, 'apiUrl' => $pattern, 'templateName' => $templateName, 'route' => $route);
     }
     return $routes;
 }