Example #1
0
 /**
  * @test
  */
 public function shouldReturnReplacedTemplateContents()
 {
     //given
     $actionGenerator = new ActionGenerator('index');
     //when
     $templateContents = $actionGenerator->templateContents();
     //then
     Assert::thatString($templateContents)->contains('public function index');
 }
Example #2
0
 public function appendAction(ActionGenerator $actionGenerator = null)
 {
     if ($actionGenerator) {
         if ($this->isActionExists($actionGenerator->getActionViewFile())) {
             return false;
         }
         $actionAppender = new ActionAppender($actionGenerator);
         return $actionAppender->toView($this)->append();
     }
     return false;
 }
Example #3
0
 public function append()
 {
     if ($this->controllerGenerator) {
         $controllerPath = $this->controllerGenerator->getControllerPath();
         $controllerContents = $this->controllerGenerator->getControllerContents();
         $actionContents = $this->actionGenerator->templateContents();
         $controllerContents = preg_replace('/}\\s*$/', $actionContents . PHP_EOL . '}' . PHP_EOL, $controllerContents);
         file_put_contents($controllerPath, $controllerContents);
     }
     if ($this->viewGenerator) {
         file_put_contents(Path::join($this->viewGenerator->getViewPath(), $this->actionGenerator->getActionViewFile()), PHP_EOL);
     }
     return true;
 }
 public function content()
 {
     $stubContent = file_get_contents($this->stubFilePath());
     $strSubstitutor = new StrSubstitutor(array('action' => $this->actionGenerator->getActionName()));
     return $strSubstitutor->replace($stubContent);
 }