示例#1
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;
 }
示例#2
0
 private function getFilePath($bundlePrefix, $pathParts)
 {
     $kernel = $this->getContainer()->get('kernel');
     $basePath = $kernel->locateResource('@' . $bundlePrefix);
     return FileUtils::concatPath($basePath, FileUtils::concatPathArray($pathParts));
 }