public function generateRequests(ParametersManager $parManager)
 {
     $menus = $parManager->getChordParameters('fminor', 'menu');
     $twig = new TwigEngine(__DIR__);
     $project = $parManager->getBaseParameter('project_name');
     $requests = array();
     foreach ($menus as $key => $menu) {
         foreach ($menu['parts'] as $menuPart) {
             if ($menuPart['type'] === 'links') {
                 foreach ($menuPart['parts'] as $part) {
                     if ($part['type'] === 'link') {
                         if (!$parManager->hasFeatureById($part['part'], 'linkable')) {
                             throw new \InvalidArgumentException("part in a link group of menu {$key} should support be linkable");
                         }
                     } elseif ($part['type'] === 'dropdown') {
                         foreach ($part['parts'] as $link) {
                             if (!$parManager->hasFeatureById($link['part'], 'linkable')) {
                                 throw new \InvalidArgumentException("part in a dropdown of menu {$key} should support be linkable");
                             }
                         }
                     }
                 }
             } elseif ($menuPart['type'] === 'embedded') {
                 if (!$parManager->hasFeatureById($menuPart['part'], 'embeddedable')) {
                     throw new \InvalidArgumentException("part type embedded in menu {$key} should support be embeddedable");
                 }
             }
         }
         $request = new TemplateRequest();
         $type = $menu['inline'] === true ? TemplateRequest::INLINE : TemplateRequest::INCLUDED;
         $request->setId('fminor.menu.' . $key)->setType($type)->setContent($twig->render('menu.php.twig', array('name' => $key, 'brand' => $menu['brand'], 'project_name' => $project, 'parts' => $menu['parts'])));
         $requests[] = $request;
     }
     return $requests;
 }
 private function createTemplate($key, $webpage)
 {
     $twig = new TwigEngine(__DIR__);
     $template = new TemplateRequest();
     $template->setId('fminor.webpage.' . $key . '.template');
     $template->setType(TemplateRequest::INCLUDED);
     $template->setContent($twig->render('webpage.php.twig', array('name' => $key, 'parts' => $webpage['parts'])));
     return $template;
 }
 public function generate(array $requests, ParametersManager $parManager)
 {
     $controllers = array();
     foreach (ControllerRequest::filter($requests) as $request) {
         if (!isset($controllers[$request->getController()])) {
             $controllers[$request->getController()] = array('name' => $request->getController(), 'actions' => array());
         }
         $controllers[$request->getController()]['actions'][] = array('name' => $request->getAction(), 'code' => $request->getCode());
     }
     $twig = new TwigEngine(__DIR__);
     foreach ($controllers as $controller) {
         $this->create('src/App/Controller/', $controller['name'] . 'Controller.php', $twig->render('controller.php.twig', array('controller' => $controller)));
     }
 }
 public function generateRequests(ParametersManager $parManager)
 {
     $sections = $parManager->getChordParameters('fminor', 'section');
     $twig = new TwigEngine(__DIR__);
     $requests = array();
     foreach ($sections as $key => $section) {
         foreach ($section['parts'] as $part) {
             if (!$parManager->hasFeatureById($part, 'embeddedable')) {
                 throw new \InvalidArgumentException('parts should support be embeddedable');
             }
         }
         $request = new TemplateRequest();
         $type = $section['inline'] === true ? TemplateRequest::INLINE : TemplateRequest::INCLUDED;
         $request->setId('fminor.section.' . $key)->setType($type)->setContent($twig->render('section.php.twig', array('name' => $key, 'parts' => $section['parts'])));
         $requests[] = $request;
     }
     return $requests;
 }
 public function generate(array $requests, ParametersManager $parManager)
 {
     $twig = new TwigEngine(__DIR__);
     $param = array('routes' => RoutingRequest::filter($requests));
     $this->create('src/Config/', 'routes.php', $twig->render('routes.php.twig', $param));
 }
 public function generate(array $requests, ParametersManager $parManager)
 {
     $twig = new TwigEngine(__DIR__);
     $assets = AssetRequest::filter($requests);
     $libraries = LibraryRequest::filter($requests);
     $libraries = $this->addBaseLibraries($libraries);
     $preferCdns = $parManager->getBaseParameter('prefer_cdn');
     $projectName = $parManager->getBaseParameter('project_name');
     $stylesReq = array();
     $scriptsReq = array();
     $styles = array();
     $scripts = array();
     $bower = array();
     $already = array();
     $libraries = array_filter($libraries, function ($library) use($already) {
         if (isset($already[$library->getId()])) {
             return false;
         } else {
             $already[$library->getId()] = true;
             return true;
         }
     });
     foreach ($libraries as $library) {
         $bowerAlr = false;
         if ($preferCdns && $library->getStyleCdns() !== null) {
             $styles = array_merge($styles, $library->getStyleCdns());
         } elseif ($library->getStylePaths() !== null) {
             $styles = array_merge($styles, $library->getStylePaths());
             $bower[] = $library->getId();
             $bowerAlr = true;
         }
         if ($preferCdns && $library->getScriptCdns() !== null) {
             $scripts = array_merge($scripts, $library->getScriptCdns());
         } elseif ($library->getScriptPaths() !== null) {
             $scripts = array_merge($scripts, $library->getScriptPaths());
             if (!$bowerAlr) {
                 $bower[] = $library->getId();
             }
         }
     }
     foreach ($assets as $asset) {
         if ($asset->getType() === AssetRequest::STYLE) {
             $stylesReq[] = $asset;
         } elseif ($asset->getType() === AssetRequest::SCRIPT) {
             $scriptsReq[] = $asset;
         }
     }
     if (count($stylesReq) > 0) {
         $styles[] = '/css/style.css';
         $param = array('assets' => $stylesReq);
         $this->create('web/css/', 'style.css', $twig->render('asset.twig', $param));
     }
     if (count($scriptsReq) > 0) {
         $styles[] = '/js/scripts.js';
         $param = array('assets' => $scriptsReq);
         $this->create('web/js/', 'scripts.js', $twig->render('asset.twig', $param));
     }
     if (count($bower) > 0) {
         $param = array('libraries' => $bower, 'project_name' => $projectName);
         $this->create('/', 'bower.json', $twig->render('bower.json.twig', $param));
     }
     $param = array('styles' => $styles, 'scripts' => $scripts, 'project_name' => $projectName);
     $this->create('src/Resources/views/', 'base.php', $twig->render('base.php.twig', $param));
 }