Esempio n. 1
0
 public function onControllerGenerated(ControllerGenerated $event)
 {
     $spec = $event->getControllerSpec();
     $controllerName = $spec->getName();
     echo "Generating Haml views for controller {$spec->getName()}:\n";
     foreach ($spec->getActions() as $actionName) {
         $this->generateView(new ViewSpec($controllerName, $actionName));
     }
 }
Esempio n. 2
0
 public function onControllerGenerated(ControllerGenerated $event)
 {
     $spec = $event->getControllerSpec();
     $controllerName = $spec->getName();
     $viewsPath = $spec->getBundle()->getPath() . '/Resources/views/' . $spec->getName() . '/';
     if (!realpath($viewsPath)) {
         mkdir($viewsPath, 0755, true);
     }
     foreach ($spec->getActions() as $actionName) {
         $view = $this->generateView(new ViewSpec($controllerName, $actionName));
         file_put_contents($viewsPath . $actionName . '.html.twig', $view);
     }
 }
Esempio n. 3
0
 public function onControllerGenerated(ControllerGenerated $event)
 {
     $spec = $event->getControllerSpec();
     $printer = new PrettyPrinter();
     $stmts = array();
     echo "Generating tests for {$spec->getName()}:\n";
     $stmts[] = $this->factory->namespace(array($spec->getBundle()->getNamespace(), 'Tests', 'Controller'));
     $stmts[] = $this->factory->use('Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase');
     $class = $this->factory->class($spec->getName() . 'ControllerTest')->extend('WebTestCase');
     foreach ($spec->getActions() as $action) {
         $class->addStmt($this->buildAction($action));
         echo "  test{$action}\n";
     }
     $stmts[] = $class;
     $nodes = array_map(function ($stmt) {
         return $stmt->getNode();
     }, $stmts);
     $code = $printer->prettyPrint($nodes);
     $testCaseFile = $spec->getBundle()->getPath() . '/Tests/Controller/' . $spec->getName() . 'ControllerTest.php';
     file_put_contents($testCaseFile, "<?php\n" . $code);
 }
Esempio n. 4
0
 public function onControllerGenerated(ControllerGenerated $event)
 {
     $spec = $event->getControllerSpec();
     $this->updateBundleRoutes($spec);
     $this->updateAppRoutes($spec);
 }