X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FConsole%2FDatabaseStructure.php;h=6b1fa8d4d6fecaad35db3b445e00ddec0735820d;hb=d53f46b9583737668a3314a22d1eeacb00a47db2;hp=3feaa64d6005cdea8442ef6756e045bad3e6851e;hpb=cd41efe29de0aa712619faf7a07e209003639250;p=friendica.git diff --git a/src/Console/DatabaseStructure.php b/src/Console/DatabaseStructure.php index 3feaa64d60..6b1fa8d4d6 100644 --- a/src/Console/DatabaseStructure.php +++ b/src/Console/DatabaseStructure.php @@ -1,22 +1,48 @@ . + * + */ namespace Friendica\Console; -use Friendica\Core; +use Friendica\Core\Config\Cache; use Friendica\Core\Update; -use Friendica\Database\DBA; +use Friendica\Database\Database; use Friendica\Database\DBStructure; use RuntimeException; /** - * @brief Performs database updates from the command line - * - * @author Hypolite Petovan + * Performs database updates from the command line */ class DatabaseStructure extends \Asika\SimpleConsole\Console { protected $helpOptions = ['h', 'help', '?']; + /** + * @var Database + */ + private $dba; + /** + * @var Cache + */ + private $configCache; + protected function getHelp() { $help = <<dba = $dba; + $this->configCache = $configCache; + } + protected function doExecute() { if ($this->getOption('v')) { @@ -56,26 +90,24 @@ HELP; throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments'); } - if (!DBA::connected()) { + if (!$this->dba->isConnected()) { throw new RuntimeException('Unable to connect to database'); } - Core\Config::load(); - - $a = get_app(); + $basePath = $this->configCache->get('system', 'basepath'); switch ($this->getArgument(0)) { case "dryrun": - $output = DBStructure::update($a->getBasePath(), true, false); + $output = DBStructure::update($basePath, true, false); break; case "update": $force = $this->getOption(['f', 'force'], false); $override = $this->getOption(['o', 'override'], false); - $output = Update::run($a->getBasePath(), $force, $override,true, false); + $output = Update::run($basePath, $force, $override,true, false); break; case "dumpsql": ob_start(); - DBStructure::printStructure($a->getBasePath()); + DBStructure::printStructure($basePath); $output = ob_get_clean(); break; case "toinnodb":