public function parseTask() { $factory = WebConsoleFactory::get($this->app); $this->command = $this->task->request->get->get('command'); $this->execute = $this->task->request->get->get('execute') == 'true'; $this->isUnverifiedExecution = true; if ($this->command == '') { $this->command = $factory->appConfig()->defaultCommand; $this->execute = true; $this->isUnverifiedExecution = false; } $this->setResult($factory->appTemplates()->load('CyantreeWebConsoleModule::console.html', null, false)); }
public function processRequest(WebConsoleRequest $request) { $factory = WebConsoleFactory::get($this->app); $config = $factory->appConfig(); $command = str_replace('/', '\\', $request->command); if (!preg_match('!^[a-zA-Z0-9_/]+$!', $command)) { $this->_response->showError('Command not found'); } else { $found = false; $className = null; foreach ($config->commandNamespaces as $commandNamespace) { $className = $commandNamespace . $command . 'Command'; if (class_exists($className)) { $found = true; break; } } if ($found) { /** @var WebConsoleCommand $c */ $c = new $className(); $c->request = $request; $c->task = $this->task; $c->app = $this->app; $c->page = $this; $c->result = $this->_response; $this->_response->redirectToCommand = $request->args->get('redirect'); $c->init(); if (!$request->isUnverifiedExecution || $c->allowUnverifiedExecution) { $c->execute(); } else { $this->_response->showError('Command doesn\'t allow direct execution via URL.'); } $c->deInit(); } else { $this->_response->showError('Command not found'); } } return $this->_response; }
/** @return WebConsoleFactory */ public function factory() { return WebConsoleFactory::get($this->app); }