예제 #1
0
 /**
  * @inheritDoc
  */
 public function generate()
 {
     $files = array();
     $db = $this->getDbConnection();
     $modelClass = ModelHelper::generateClassName($db, $db->tablePrefix, $this->subject);
     $controllerUse = !empty($this->modelNamespace) ? array("{$this->context}\\{$this->modelNamespace}\\{$modelClass}") : array();
     $files = array_merge($files, Generator::run(Generator::MODEL, array('subject' => $this->subject, 'context' => $this->context, 'template' => $this->modelTemplate, 'templatePath' => $this->getTemplatePath(), 'baseClass' => $this->modelBaseClass, 'namespace' => $this->modelNamespace)), Generator::run(Generator::CONTROLLER, array('subject' => $this->subject, 'context' => $this->context, 'template' => $this->controllerTemplate, 'templatePath' => $this->getTemplatePath(), 'baseClass' => $this->controllerBaseClass, 'namespace' => $this->controllerNamespace, 'actions' => $this->actions, 'providers' => array(array(Provider::CRUD, 'modelClass' => $modelClass, 'use' => $controllerUse)))));
     return $files;
 }
예제 #2
0
 /**
  * @inheritDoc
  */
 public function generate()
 {
     $files = array();
     foreach ($this->generators as $name => $items) {
         foreach ($items as $config) {
             $config['subject'] = array_shift($config);
             $config['context'] = $this->subject;
             $files = array_merge(Generator::run($name, $config), $files);
         }
     }
     foreach ($this->directories as $dir) {
         $files[] = $this->createGitKeepFile($dir);
     }
     return $files;
 }
예제 #3
0
 /**
  * @inheritDoc
  */
 public function generate()
 {
     $files = array();
     $this->actions = $this->normalizeActions($this->actions);
     $files[] = new File($this->resolveFilePath(), $this->compile(array('className' => $this->className, 'baseClass' => $this->baseClass, 'namespace' => $this->namespace, 'actions' => $this->renderActions())));
     foreach ($this->actions as $actionId) {
         if ($this->resolveTemplateFile(array("views/{$actionId}.txt", "views/view.txt")) === null) {
             continue;
         }
         $files = array_merge($files, Generator::run(Generator::VIEW, array('subject' => $actionId, 'context' => $this->context, 'template' => $this->template, 'filePath' => "views/{$this->subject}", 'templatePath' => "{$this->getTemplatePath()}/views", 'providers' => array(array(Provider::VIEW, 'cssClass' => "{$this->subject}-controller {$actionId}-action", 'vars' => array('this' => $this->resolveControllerClass()))))));
     }
     return $files;
 }