/** * Generate controller */ public function createAction() { if ($this->request->isPost()) { $controllerName = $this->request->getPost('name', 'string'); $force = $this->request->getPost('force', 'int'); try { $controllerBuilder = new \Phalcon\Builder\Controller(array('name' => $controllerName, 'directory' => null, 'namespace' => null, 'baseClass' => null, 'force' => $force)); $fileName = $controllerBuilder->build(); $this->flash->success('The controller "' . $fileName . '" was created successfully'); return $this->dispatcher->forward(array('controller' => 'controllers', 'action' => 'edit', 'params' => array($fileName))); } catch (BuilderException $e) { $this->flash->error($e->getMessage()); } } return $this->dispatcher->forward(array('controller' => 'controllers', 'action' => 'index')); }
/** * Create indexController file * * @return void */ private function createControllerFile($path, $name) { $modelBuilder = new \Phalcon\Builder\Controller(array('name' => 'index', 'controllersDir' => '../' . $path . 'apps/frontend/controllers/', 'namespace' => ucfirst($name) . '\\Frontend\\Controllers', 'baseClass' => 'ControllerBase')); $modelBuilder->build(); }
/** * Run the command */ public function run($parameters) { $controllerName = $this->getOption(array('name', 1)); $controllerBuilder = new \Phalcon\Builder\Controller(array('name' => $controllerName, 'directory' => $this->getOption('directory'), 'namespace' => $this->getOption('namespace'), 'baseClass' => $this->getOption('base-class'), 'force' => $this->isReceivedOption('force'))); return $controllerBuilder->build(); }
/** * Create indexController file * * @param $path */ private function createControllerFile($path) { $modelBuilder = new \Phalcon\Builder\Controller(array('name' => 'index', 'directory' => $path, 'controllersDir' => $path . 'app/controllers', 'baseClass' => 'ControllerBase')); $modelBuilder->build(); }