logger = $logger; $this->userId = $userId; $this->application = new Application( OC::$server->getConfig(), OC::$server->getEventDispatcher(), new FakeRequest(), OC::$server->getLogger(), OC::$server->query(MemoryInfo::class) ); $this->application->setAutoExit(false); $this->output = new OccOutput(OutputInterface::VERBOSITY_NORMAL, true); $this->application->loadCommands(new StringInput(""), $this->output); } /** * @NoCSRFRequired */ public function index() { return new TemplateResponse('occweb', 'index'); } /** * @param $input * @return string */ private function run($input) { try { $this->application->run($input, $this->output); return $this->output->fetch(); } catch (Exception $ex) { $this->logger->logException($ex); return "error: " . $ex->getMessage(); } } /** * @param string $command * @return DataResponse */ public function cmd($command) { $this->logger->debug($command); $input = new StringInput($command); $response = $this->run($input); $this->logger->debug($response); return new DataResponse($response); } public function list() { $defs = $this->application->application->all(); $cmds = array(); foreach ($defs as $d) { array_push($cmds, $d->getName()); } return new DataResponse($cmds); } }