Exemple #1
0
 public function createEntityAction()
 {
     $request = $this->getRequest();
     $table = $request->getParam('table');
     $savePath = $request->getParam('path');
     $namespace = $request->getParam('namespace');
     $this->createEntityService->create($table, $savePath, $namespace);
     $this->console->write(Util::format("Done, entity is created from {$table}!"), Color::GREEN);
 }
Exemple #2
0
 public function removeModuleAction()
 {
     try {
         $request = $this->getRequest();
         $module = $request->getParam('module');
         $this->createModuleService->remove($module);
         $this->console->write(Util::format("Module {$module} is removed!"), Color::GREEN);
     } catch (Exception $e) {
         $this->console->write(Util::format($e->getMessage()), Color::RED);
     }
 }
Exemple #3
0
 public function createMapperAction()
 {
     /**
      * CreateMapperService constructor.
      * @param $tableName
      * @param $parentClassName
      * @param $mapperName
      * @param $namespace
      * @param $path
      */
     $request = $this->getRequest();
     $tableName = $request->getParam('table');
     $parent = $request->getParam('parent');
     $mapper = $request->getParam('mapper');
     $namespace = $request->getParam('namespace');
     $path = $request->getParam('path');
     $this->createMapperService->create($tableName, $parent, $mapper, $namespace, $path);
     $this->console->write(Util::format('Mapper is created!'), Color::GREEN);
 }
Exemple #4
0
 protected function applyMigration(array $migration, $down = false)
 {
     try {
         /** @var $migrationObject AbstractMigration */
         $migrationObject = new $migration['class']($this->serviceLocator);
         $this->console->writeLine(sprintf("%s Execute migration class %s.", $migration['class'], $down ? 'down' : 'up'));
         if ($down) {
             $migrationObject->down();
             $this->versionTable->delete($migration['version']);
         } else {
             $migrationObject->up();
             $this->versionTable->save($migration['version']);
         }
     } catch (InvalidQueryException $e) {
         $previousMessage = $e->getPrevious() ? $e->getPrevious()->getMessage() : null;
         $msg = sprintf('%s: "%s"; File: %s; Line #%d', $e->getMessage(), $previousMessage, $e->getFile(), $e->getLine());
         throw new \Exception($msg, $e->getCode(), $e);
     } catch (\Exception $e) {
         $msg = sprintf('%s; File: %s; Line #%d', $e->getMessage(), $e->getFile(), $e->getLine());
         throw new \Exception($msg, $e->getCode(), $e);
     }
 }
Exemple #5
0
 /**
  * Read a single character from the console input
  *
  * @param string|null   $mask   A list of allowed chars
  * @return string
  */
 public function readChar($mask = null)
 {
     /**
      * Decide if we can use `choice` tool
      */
     $useChoice = $mask !== null && preg_match('/^[a-zA-Z0-9]$', $mask);
     do {
         if ($useChoice) {
             system('choice /n /cs /c ' . $mask, $return);
             if ($return == 255 || $return < 1 || $return > strlen($mask)) {
                 throw new RuntimeException('"choice" command failed to run. Are you using Windows XP or newer?');
             } else {
                 /**
                  * Fetch the char from mask
                  */
                 $char = substr($mask, $return - 1, 1);
             }
         } else {
             $char = parent::readChar($mask);
         }
     } while (!$char || $mask !== null && !stristr($mask, $char));
     return $char;
 }