appendAction() public méthode

public appendAction ( ActionGenerator $actionGenerator = null )
$actionGenerator ActionGenerator
Exemple #1
0
 /**
  * @test
  */
 public function shouldNotAppendFileWhenExists()
 {
     //given
     $viewGenerator = new ViewGenerator('users', $this->path);
     $viewGenerator->createViewDirectoryIfNotExists();
     $actionGenerator = new ActionGenerator('save');
     $viewGenerator->appendAction($actionGenerator);
     //when
     $appendAction = $viewGenerator->appendAction($actionGenerator);
     //then
     $this->assertFalse($appendAction);
 }
 private function generate()
 {
     $controller = $this->input->getArgument('controller');
     $action = $this->input->getArgument('action');
     $controllerGenerator = new ControllerGenerator($controller);
     $actionGenerator = null;
     if ($action) {
         $actionGenerator = new ActionGenerator($action);
     }
     $this->output->writeln('---------------------------------');
     $this->output->writeln('Class name: <info>' . $controllerGenerator->getClassName() . '</info>');
     $this->output->writeln('Class namespace: <info>' . $controllerGenerator->getClassNamespace() . '</info>');
     $this->output->writeln('---------------------------------');
     if (!$controllerGenerator->isControllerExists()) {
         $this->output->writeln('Create: <info>' . $controllerGenerator->getControllerPath() . '</info>');
         $controllerGenerator->saveController();
     }
     if ($controllerGenerator->appendAction($actionGenerator)) {
         $this->output->writeln('Appened action: <info>' . $controllerGenerator->getClassName() . '::' . $actionGenerator->getActionName() . '</info>');
     }
     $viewGenerator = new ViewGenerator($controller);
     if ($viewGenerator->createViewDirectoryIfNotExists()) {
         $this->output->writeln('Create: <info>' . $viewGenerator->getViewPath() . '</info>');
     }
     if ($viewGenerator->appendAction($actionGenerator)) {
         $this->output->writeln('Appened view file: <info>' . $actionGenerator->getActionViewFile() . '</info>');
     }
 }