<?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
namespace Friendica\Console;
-use Friendica\Core;
+use Friendica\App;
+use Friendica\Core\Config\IConfig;
/**
- * @brief Sets maintenance mode for this node
- *
- * @author Hypolite Petovan <hypolite@mrpetovan.com>
+ * Sets maintenance mode for this node
*/
class Maintenance extends \Asika\SimpleConsole\Console
{
protected $helpOptions = ['h', 'help', '?'];
+ /**
+ * @var App\Mode
+ */
+ private $appMode;
+ /**
+ * @var IConfig
+ */
+ private $config;
+
protected function getHelp()
{
$help = <<<HELP
return $help;
}
- protected function doExecute()
+ public function __construct(App\Mode $appMode, IConfig $config, $argv = null)
{
- $a = \Friendica\BaseObject::getApp();
+ parent::__construct($argv);
+ $this->appMode = $appMode;
+ $this->config = $config;
+ }
+
+ protected function doExecute()
+ {
if ($this->getOption('v')) {
$this->out('Class: ' . __CLASS__);
$this->out('Arguments: ' . var_export($this->args, true));
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
- if ($a->getMode()->isInstall()) {
+ if ($this->appMode->isInstall()) {
throw new \RuntimeException('Database isn\'t ready or populated yet');
}
$enabled = intval($this->getArgument(0));
- Core\Config::set('system', 'maintenance', $enabled);
+ $this->config->set('system', 'maintenance', $enabled);
$reason = $this->getArgument(1);
if ($enabled && $this->getArgument(1)) {
- Core\Config::set('system', 'maintenance_reason', $this->getArgument(1));
+ $this->config->set('system', 'maintenance_reason', $this->getArgument(1));
} else {
- Core\Config::set('system', 'maintenance_reason', '');
+ $this->config->set('system', 'maintenance_reason', '');
}
if ($enabled) {