/**
  * We will execute the crud command and generate files
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** Check for argument database name if not given we will use default
      *  database connection
      */
     $this->database = !is_null($input->getArgument('database')) ? $input->getArgument('database') : $this->tableSchema->getDefaultDatabaseConnection();
     $this->table = !is_null($input->getArgument('name')) ? $input->getArgument('name') : 'Form';
     $this->columns = $this->getColumns();
     $this->applicationDir = CYGNITE_BASE . DS . APPPATH;
     $this->generateForm();
     $output->writeln("<info>Form " . APPPATH . "/components/form/" . Inflector::classify($this->table) . "Form" . EXT . " Generated Successfully By Cygnite Cli.</info>");
 }
 /**
  * We will execute the controller command and generate classes
  *
  * @return mixed|void
  * @throws \Exception
  */
 public function process()
 {
     // Your controller name
     $this->controller = Inflector::classify($this->argument('name')) . 'Controller';
     // By default we will generate basic controller, if resource set then we will generate
     // REST-ful Resource controller
     $this->setControllerType();
     try {
         $this->makeController();
     } catch (\Exception $e) {
         throw $e;
     }
     $this->info('Controller ' . $this->controller . ' Generated Successfully By Cygnite Cli.');
 }
 /**
  * We will execute the controller command and generate classes
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @throws \Exception
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Your controller name
     $this->controller = Inflector::classify($input->getArgument('name')) . 'Controller';
     // By default we will generate basic controller, if resource set then we will generate
     // REST-ful Resource controller
     $this->setControllerType($input);
     try {
         $this->makeController();
     } catch (\Exception $e) {
         throw $e;
     }
     $output->writeln('<info>Controller ' . $this->controller . ' Generated Successfully By Cygnite Cli.</info>');
 }
Exemple #4
0
 /**
  * Generate Form
  */
 public function generate()
 {
     $filePath = '';
     $formName = Inflector::classify($this->formCommand->table);
     if (file_exists($this->getFormTemplatePath() . 'Form' . EXT)) {
         //We will generate Form Component
         $formContent = file_get_contents($this->getFormTemplatePath() . 'Form' . EXT);
     } else {
         die("Form template doesn't exists in " . $this->getFormTemplatePath() . 'Form' . EXT . " directory.");
     }
     $this->controller->isFormGenerator = true;
     $this->controller->updateTemplate();
     $this->controller->controller = $formName;
     $this->controller->applicationDir = CYGNITE_BASE . DS . APPPATH;
     $formContent = str_replace('%controllerName%', $formName, $formContent);
     $formContent = str_replace('{%formElements%}', $this->controller->getForm() . PHP_EOL, $formContent);
     $this->controller->generateFormComponent($formContent);
 }
 /**
  * We will execute the crud command and generate files
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @return int|null|void
  * @throws \Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Your controller name
     $this->controller = Inflector::classify($input->getArgument('name')) . 'Controller';
     // Model name
     $this->model = Inflector::classify($input->getArgument('model'));
     /** Check for argument database name if not given we will use default
      *  database connection
      */
     $this->database = !is_null($input->getArgument('database')) ? $input->getArgument('database') : $this->tableSchema->getDefaultDatabaseConnection();
     // By default we will generate plain php layout and view pages
     $this->viewType = $input->getOption('template') == false ? 'php' : 'twig';
     $this->columns = $this->getColumns();
     if (empty($this->columns)) {
         throw new \Exception("Please provide valid table name. It seems doesn't exists in the database.");
     }
     $this->applicationDir = CYGNITE_BASE . DS . APPPATH;
     $this->output = $output;
     $this->generateController();
     $this->generateModel();
     $this->generateViews();
     $output->writeln("<info>Crud Generated Successfully By Cygnite Cli.</info>");
 }
Exemple #6
0
 public function testClassifyMethod()
 {
     $this->assertEquals('AdminUser', Inflector::classify('admin_user'));
     $this->assertEquals('AdminUser', Inflector::classify('admin-user'));
 }
 /**
  * <code>
  * // Call the "index" method on the "user" controller
  *  $response = $this->call('admin::user@index');.
  *
  * // Call the "user/admin" controller and pass parameters
  *   $response = $this->call('modules.admin.user@profile', $arguments);
  * </code>
  */
 public function call($resource, $arguments = [])
 {
     list($name, $method) = explode('@', $resource);
     $method = $method . 'Action';
     $class = array_map('ucfirst', explode('.', $name));
     $className = Inflector::classify(end($class)) . 'Controller';
     $namespace = str_replace(end($class), '', $class);
     $class = '\\' . APP_NS . '\\' . implode('\\', $namespace) . $className;
     return $this->_call(new $class(), $method, $arguments);
 }
Exemple #8
0
 /**
  * @param      $args
  * @param      $param
  * @param bool $module
  */
 private function setControllerConfig($args, $param, $module = false)
 {
     $this->controller = Inflector::classify($param[0]) . 'Controller';
     if ($module) {
         $this->namespace = '\\' . ucfirst($this->getModuleDir()) . '\\' . $args[0] . '\\Controllers\\';
     }
     $this->controllerWithNS = "\\" . ucfirst(APPPATH) . $this->namespace . $this->controller;
     $this->method = Inflector::camelize($param[1]) . 'Action';
 }
Exemple #9
0
 /**
  * @param $controller
  * @param $action
  * @return mixed
  */
 protected function setDeleteRoute($controller, $action)
 {
     $this->routes['get'] = array_merge($this->routes['get'], ["/{$controller}/{$action}/{:id}/" => Inflector::classify($controller) . '@' . $action]);
     return $this;
 }
 /**
  * @param      $class
  * @param      $dir
  * @return string
  */
 public function getControllerName($class, $dir = '')
 {
     $dir = $dir !== '' ? $dir . '\\' : '';
     return "\\" . str_replace('src/', '', APPPATH) . $this->namespace . $dir . Inflector::classify($class) . 'Controller';
 }
 /**
  * We will execute the command and generate model class.
  *
  * @return int|null|void
  */
 public function process()
 {
     $table = $this->argument('name');
     // Your model name
     $this->model = Inflector::classify($table);
     /*
     | Check for argument database name if not given
     | we will use default database connection
     */
     $this->database = $this->getDatabase();
     $this->columns = $this->getColumns();
     if (empty($this->columns)) {
         exit($this->error("Please check your model name. It seems table '{$table}' doesn't exists!"));
     }
     $this->applicationDir = CYGNITE_BASE . DS . APPPATH;
     $this->generateModel();
     $modelPath = APPPATH . DS . 'Models' . DS . $this->model . EXT;
     $this->info("Model {$this->model} Generated Successfully Into " . $modelPath);
 }
Exemple #12
0
 /**
  * Generate form component
  * @param $formContent
  * @return bool
  */
 public function generateFormComponent($formContent)
 {
     /*write operation ->*/
     $writeTmp = fopen($this->applicationDir . DS . 'components' . DS . 'form' . DS . Inflector::classify(str_replace('Controller', '', $this->controller)) . 'Form' . EXT, "w") or die('Unable to generate controller');
     $contentAppendWith = '';
     $contentAppendWith = '<?php ' . PHP_EOL;
     $formContent = str_replace('{%Apps%}', ucfirst(APPPATH), $formContent);
     fwrite($writeTmp, $contentAppendWith . $formContent);
     fclose($writeTmp);
     return true;
 }
Exemple #13
0
 /**
  * Call migration and do update
  *
  * @param string $type
  */
 public function updateMigration($type = 'up')
 {
     $file = $class = null;
     $file = $this->getAppMigrationDirPath() . $this->getVersion() . $this->getMigrationClass();
     if (is_readable($file . EXT)) {
         include_once $file . EXT;
         $class = Inflector::classify($this->getMigrationClass());
     }
     if (trim($type) !== 'down') {
         $type = 'up';
     }
     call_user_func_array([new $class(), $type], []);
     $this->updateMigrationTable();
     $this->command->info("Migrated: {$file} OK!");
 }
 /**
  * Default routes actions: index, add, edit, show, delete
  * Additional routing to the controller: order-info -> orderInfoAction()
  *
  *
  * @param $controller
  * @param $action
  * @return mixed
  */
 protected function setOrderInfoRoute($controller, $action)
 {
     $controllerName = Inflector::classify($controller);
     $actionName = Inflector::classify($action);
     return $this->mapRoute("/{$controller}/{$action}/", $controllerName . '.' . $actionName);
 }
 /**
  * We will execute the crud command and generate files
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @throws \Exception
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Your model name
     $this->model = Inflector::classify($input->getArgument('name'));
     // Check for argument database name if not given we will use default
     // database connection
     $this->database = $this->getDatabase($input);
     $this->columns = $this->getColumns();
     if (empty($this->columns)) {
         throw new \Exception("Please check your model name. It seems doesn't exists in the database.");
     }
     $this->applicationDir = CYGNITE_BASE . DS . APPPATH;
     $this->generateModel();
     $modelPath = $this->applicationDir . DS . 'models' . DS . $this->model . EXT;
     $output->writeln("Model {$this->model} generated successfully into " . $modelPath);
 }
Exemple #16
0
 /**
  * @param      $class
  * @param      $dir
  * @return string
  */
 public function getController($class, $dir = '')
 {
     $dir = $dir !== '' ? $dir . '\\' : '';
     return "\\" . ucfirst(APPPATH) . $this->namespace . $dir . Inflector::classify($class) . 'Controller';
 }
Exemple #17
0
 private function replaceCreateOrUpdateTemplateContents($content)
 {
     /* Create View Page */
     // replace controller name - #controllerName#
     /* Update View Page */
     // replace controller name - #controllerName#
     $controller = str_replace('Controller', '', $this->controller);
     $content = str_replace('#controllerName#', strtolower($this->controller), $content);
     $content = str_replace('#Controller#', Inflector::classify($this->controller), $content);
     return $content;
 }
Exemple #18
0
 /**
  * @param $controller
  * @param $action
  * @return mixed
  */
 protected function setDeleteRoute($controller, $action)
 {
     return $this->mapRoute("/{$controller}/{$action}/{:id}/", Inflector::classify($controller) . '@' . $action);
 }
Exemple #19
0
 /**
  * Call migration and do update.
  *
  * @param string $type
  */
 public function updateMigration($type = 'up')
 {
     $file = $class = null;
     $file = $this->getAppMigrationDirPath() . $this->getVersion() . $this->getMigrationClass();
     if (is_readable($file . EXT)) {
         include_once $file . EXT;
         $class = Inflector::classify($this->getMigrationClass());
     }
     if (trim($type) !== 'down') {
         $type = 'up';
     }
     //Create migrations table schema if not exists
     $this->command->table()->makeMigration();
     call_user_func_array([new $class(), $type], []);
     $this->updateMigrationTable();
     $this->command->info('Migrated: ' . $file . EXT . ' OK!');
 }
 /**
  * We will execute the crud command and generate files.
  *
  *
  * @return int|null|void
  */
 public function process()
 {
     // Your controller name
     $this->controller = Inflector::classify($this->argument('name')) . 'Controller';
     // Model name
     $this->model = Inflector::classify($this->argument('model'));
     /*
     | Check for argument database name if not given we will use default
     |  database connection
     */
     $this->database = !is_null($this->argument('database')) ? $this->argument('database') : $this->table()->getDefaultDatabaseConnection();
     // By default we will generate plain php layout and view pages
     $this->viewType = $this->option('template') == false ? 'php' : 'twig';
     $this->columns = $this->getColumns();
     if (empty($this->columns)) {
         exit($this->error("Please provide valid table name. It seems doesn't exists in the database."));
     }
     $this->applicationDir = CYGNITE_BASE . DS . APPPATH;
     $this->generateController();
     $this->generateModel();
     $this->generateViews();
     $controller = str_replace('Controller', '', $this->controller);
     $this->comment("\n" . 'You need to route the controller to access methods from browser, add
     $this->routesController->controller("' . $controller . '"); inside the method ' . "\n" . '
     \\Apps\\Routing\\RouteCollection::executeStaticRoutes();' . "\n");
     $this->info('Crud Generated Successfully By Cygnite Cli.');
 }
Exemple #21
0
 /**
  * Call migration and do update
  *
  * @param string $type
  */
 public function updateMigration($type = 'up')
 {
     $file = $class = null;
     $file = $this->migrationDir . $this->getVersion() . $this->getMigrationClass() . EXT;
     if (is_readable($file)) {
         include_once $file;
         $class = Inflector::classify($this->getMigrationClass());
     }
     if (trim($type) !== 'down') {
         $type = 'up';
     }
     call_user_func_array(array(new $class(), $type), array());
     $this->updateMigrationTable();
 }
 /**
  * We will execute the crud command and generate files.
  *
  * @return int|null|void
  */
 public function process()
 {
     /*
     | Check for argument database name if not given we will use default
     |  database connection
     */
     $this->database = !is_null($this->argument('database')) ? $this->argument('database') : $this->table()->getDefaultDatabaseConnection();
     $this->tableName = !is_null($this->argument('name')) ? $this->argument('name') : 'Form';
     $this->columns = $this->getColumns();
     $this->applicationDir = realpath(CYGNITE_BASE . DS . APPPATH);
     $this->generateForm();
     $this->info('Form ' . APPPATH . '/Form/' . Inflector::classify($this->tableName) . 'Form' . EXT . ' Generated Successfully!.');
 }
Exemple #23
0
 /**
  * @param $controller
  * @param $class
  * @param $reflectionArray
  *
  * @throws \Cygnite\DependencyInjection\Exceptions\DependencyException
  *
  * @return array
  */
 private function checkPropertyAndMakeObject($controller, $class, $reflectionArray)
 {
     list($reflectionClass, $classProperty) = $reflectionArray;
     if (!$reflectionClass->hasProperty($classProperty)) {
         throw new DependencyException(sprintf("Property %s is not defined in {$controller} controller", $classProperty));
     }
     $controllerProp = Inflector::classify($classProperty);
     $object = $this->make($class);
     return [$object, $controllerProp];
 }