config = $config; $this->trans = $trans; $this->urlGenerator = $urlGenerator; $this->crypt = $crypt; } /** * Configures the current command. */ protected function configure() { $this ->setName("onlyoffice:documentserver") ->setDescription("Manage document server") ->addOption( "check", null, InputOption::VALUE_NONE, "Check connection document server" ); } /** * Executes the current command. * * @param InputInterface $input - input data * @param OutputInterface $output - output data * * @return int 0 if everything went fine, or an exit code */ protected function execute(InputInterface $input, OutputInterface $output) { $check = $input->getOption("check"); $documentserver = $this->config->getDocumentServerUrl(true); if (empty($documentserver)) { $output->writeln("Document server is not configured"); return 1; } if ($check) { $documentService = new DocumentService($this->trans, $this->config); list($error, $version) = $documentService->checkDocServiceUrl($this->urlGenerator, $this->crypt); $this->config->setSettingsError($error); if (!empty($error)) { $output->writeln("Error connection: $error"); return 1; } else { $output->writeln("Document server $documentserver version $version is successfully connected"); return 0; } } $output->writeln("The current document server: $documentserver"); return 0; } }