mirror of
https://github.com/friendica/friendica
synced 2025-04-22 03:50:11 +00:00
Use DICE for Console
- Use Friendica\Core\Console as Controller for DI-library - Refactor every console command to use DICE (when possible) - Adjusting tests
This commit is contained in:
parent
b8a336cc0d
commit
a60eb9e33d
20 changed files with 400 additions and 166 deletions
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Friendica\Core;
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
use Friendica\Core\Update;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBStructure;
|
||||
use RuntimeException;
|
||||
|
||||
|
@ -17,6 +17,15 @@ class DatabaseStructure extends \Asika\SimpleConsole\Console
|
|||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var Database
|
||||
*/
|
||||
private $dba;
|
||||
/**
|
||||
* @var ConfigCache
|
||||
*/
|
||||
private $configCache;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -39,6 +48,14 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(Database $dba, ConfigCache $configCache, $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->configCache = $configCache;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
if ($this->getOption('v')) {
|
||||
|
@ -56,26 +73,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":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue