示例#1
0
 /**
  * {@inheritdoc}
  *
  * @param array $parameters
  * @return mixed
  */
 public function run(array $parameters)
 {
     $name = $this->getOption(['table-name', 1]);
     $templatePath = $this->getOption(['template-path'], null, TEMPLATE_PATH);
     $schema = $this->getOption('schema');
     $templateEngine = $this->getOption(['template-engine'], null, "php");
     $scaffoldBuilder = new ScaffoldBuilder(['name' => $name, 'schema' => $schema, 'force' => $this->isReceivedOption('force'), 'genSettersGetters' => $this->isReceivedOption('get-set'), 'directory' => $this->getOption('directory'), 'templatePath' => $templatePath, 'templateEngine' => $templateEngine, 'modelsNamespace' => $this->getOption('ns-models'), 'controllersNamespace' => $this->getOption('ns-controllers')]);
     return $scaffoldBuilder->build();
 }
 /**
  * Generate Scaffold
  */
 public function generateAction()
 {
     if ($this->request->isPost()) {
         $schema = $this->request->getPost('schema', 'string');
         $tableName = $this->request->getPost('tableName', 'string');
         $version = $this->request->getPost('version', 'string');
         $force = $this->request->getPost('force', 'int');
         $genSettersGetters = $this->request->getPost('genSettersGetters', 'int');
         try {
             $scaffoldBuilder = new Scaffold(array('name' => $tableName, 'schema' => $schema, 'force' => $force, 'genSettersGetters' => $genSettersGetters, 'directory' => null, 'templatePath' => TEMPLATE_PATH));
             $scaffoldBuilder->build();
             $this->flash->success('Scaffold for table "' . $tableName . '" was generated successfully');
         } catch (BuilderException $e) {
             $this->flash->error($e->getMessage());
         }
     }
     return $this->dispatcher->forward(array('controller' => 'scaffold', 'action' => 'index'));
 }
 /**
  * Generate Scaffold
  */
 public function generateAction()
 {
     if ($this->request->isPost()) {
         $schema = $this->request->getPost('schema', 'string');
         $tableName = $this->request->getPost('tableName', 'string');
         $templateEngine = $this->request->getPost('templateEngine');
         $force = $this->request->getPost('force', 'int');
         $genSettersGetters = $this->request->getPost('genSettersGetters', 'int');
         $directory = $this->request->getPost('directory');
         $modelsNamespace = $this->request->getPost('modelsNamespace', 'trim');
         try {
             $scaffoldBuilder = new Scaffold(['name' => $tableName, 'schema' => $schema, 'force' => $force, 'genSettersGetters' => $genSettersGetters, 'directory' => $directory, 'templatePath' => TEMPLATE_PATH, 'templateEngine' => $templateEngine, 'modelsNamespace' => $modelsNamespace]);
             $scaffoldBuilder->build();
             $message = sprintf('Scaffold for table "%s" was generated successfully', Utils::camelize($tableName));
             $this->flash->success($message);
             $this->dispatcher->forward(['controller' => 'scaffold', 'action' => 'index']);
             return;
         } catch (BuilderException $e) {
             $this->flash->error($e->getMessage());
         }
     }
     $this->dispatcher->forward(['controller' => 'scaffold', 'action' => 'index']);
 }