]> git.mxchange.org Git - friendica.git/blobdiff - src/Console/Maintenance.php
doc/themes.md,FAQ-admin: point to live friendica-themes.com mirror
[friendica.git] / src / Console / Maintenance.php
index 080eb092b75856557677375e5cbb76fe7a52ab82..7e731828466d8d2f5b176bb9f149948c389007b3 100644 (file)
@@ -1,18 +1,45 @@
 <?php
+/**
+ * @copyright Copyright (C) 2010-2022, the Friendica project
+ *
+ * @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\Capability\IManageConfigValues;
 
 /**
- * @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 IManageConfigValues
+        */
+       private $config;
+
        protected function getHelp()
        {
                $help = <<<HELP
@@ -42,10 +69,16 @@ HELP;
                return $help;
        }
 
-       protected function doExecute()
+       public function __construct(App\Mode $appMode, IManageConfigValues $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));
@@ -61,20 +94,20 @@ HELP;
                        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) {