public final function execute($action) { $action = 'execute' . Inflection::hungaryNotationToCamel($action); if (method_exists($this, $action)) { $this->getEventDispatcher()->dispatch('onBeginControllerExecute', new Event($this, array('action' => $action))); $this->beforeExecute(); $this->{$action}(); $this->afterExecute(); $this->getEventDispatcher()->dispatch('onAfterControllerExecute', new Event($this, array('action' => $action))); } else { Base::end('ERROR: task ' . Inflection::hungaryNotationToCamel($this->_name) . ':' . $action . ' not existed!' . PHP_EOL); } }
public function run() { $this->beforeRun(); $this->getEventDispatcher()->dispatch('onBeginRequest', new Event($this)); if (null == $this->_task) { throw new Exception("Missing 'task' parameter!"); } $camelName = Inflection::hungaryNotationToCamel($this->_task); $class = $this->getAppNamespace() . '\\Task\\' . $camelName; $taskPath = TASK_DIR . 'Task/' . str_replace('\\', DIRECTORY_SEPARATOR, $camelName) . '.php'; if (file_exists($taskPath)) { // require_once $file; $this->_controller = new $class($this->_task, $taskPath); $this->_controller->execute($this->_act); $this->_finished = true; } else { Base::end("ERROR: task {$this->_task} ({$taskPath}/{$class}Task.php) not existed" . PHP_EOL); } $this->getEventDispatcher()->dispatch('onEndRequest', new Event($this)); $this->afterRun(); }
public function run() { $tables = $this->_getTablesList(); $this->package = Inflection::hungaryNotationToCamel($this->package); echo "\n\n"; for ($i = 0, $size = sizeof($tables); $i < $size; ++$i) { $table = $tables[$i]; $this->_generateBaseModel($table); $this->_generateModel($table); } }
public function run() { if (null == $this->_conn) { die('Connection fail'); } $tables = $this->_getTablesList(); $this->package = Inflection::hungaryNotationToCamel($this->package); echo "\n\n"; $tableDestination = array(); for ($i = 0, $size = sizeof($tables); $i < $size; ++$i) { /*$ignore = $this->_isInIgnoreList($tables[$i]); $allow = $this->_isInAllowList($tables[$i]); $build = (!$ignore) && $allow; if (!$build) continue;*/ $schemaName = str_replace(' ', '', ucwords(str_replace('_', ' ', trim(str_replace($this->tbPrefix, '', $tables[$i]), '_')))); array_push($tableDestination, $tables[$i]); $schema = $this->_generateSchemas($tables[$i], $schemaName); echo " -- Generate schema " . $schema . " success \n"; } $this->getSpecialTbl() != false ? $note = '[SOME]' : ($note = '[ALL]'); echo "\nAre you sure you want to generate " . $note . " OMs ?\nType 'yes' to continue or 'no' to abort': "; $handle = fopen("php://stdin", "r"); if (trim(fgets($handle)) != 'yes') { echo 'Gen OMs aborted!'; exit; } $nextRunning = "php command gen:models --config=" . $this->_configKey; if ($this->getSpecialTbl() != false) { $tableToModels = @implode(',', $tableDestination); $nextRunning .= " --table=" . $tableToModels; } echo shell_exec($nextRunning); exit; }
public function _generateBaseController() { $temp = "<?php" . PHP_EOL; $appName = Inflection::hungaryNotationToCamel($this->appName); $class = $this->appName . 'Base'; $webController = 'ApiController'; $temp .= 'namespace ' . $appName . '\\Controller;' . PHP_EOL; $temp .= 'use Flywheel\\Controller\\ApiController;' . PHP_EOL; $temp .= 'abstract class ' . $class . ' extends ' . $webController . '{' . PHP_EOL . '' . PHP_EOL . '}' . PHP_EOL; $fs = new Filesystem\Filesystem(); $destinationDir = $this->appDir . 'Controller' . DIRECTORY_SEPARATOR . $class . '.php'; if ($fs->exists($destinationDir) === false) { $fs->dumpFile($destinationDir, $temp); echo "-- " . $class . " is generated success !\n"; } else { echo "-- " . $class . " is exists, aborted !\n"; } }