Check.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. * @author Thomas Müller <thomas.mueller@tmit.eu>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OC\Core\Command;
  27. use OC\SystemConfig;
  28. use Symfony\Component\Console\Input\InputInterface;
  29. use Symfony\Component\Console\Output\OutputInterface;
  30. class Check extends Base {
  31. /**
  32. * @var SystemConfig
  33. */
  34. private $config;
  35. public function __construct(SystemConfig $config) {
  36. parent::__construct();
  37. $this->config = $config;
  38. }
  39. protected function configure() {
  40. parent::configure();
  41. $this
  42. ->setName('check')
  43. ->setDescription('check dependencies of the server environment')
  44. ;
  45. }
  46. protected function execute(InputInterface $input, OutputInterface $output): int {
  47. $errors = \OC_Util::checkServer($this->config);
  48. if (!empty($errors)) {
  49. $errors = array_map(function ($item) {
  50. return (string) $item['error'];
  51. }, $errors);
  52. $this->writeArrayInOutputFormat($input, $output, $errors);
  53. return 1;
  54. }
  55. return 0;
  56. }
  57. }