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:
Philipp Holzer 2019-07-28 22:06:33 +02:00
parent b8a336cc0d
commit a60eb9e33d
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
20 changed files with 400 additions and 166 deletions

View file

@ -20,6 +20,11 @@ class Cache extends \Asika\SimpleConsole\Console
{
protected $helpOptions = ['h', 'help', '?'];
/**
* @var App\Mode
*/
private $appMode;
protected function getHelp()
{
$help = <<<HELP
@ -54,10 +59,15 @@ HELP;
return $help;
}
public function __construct(App\Mode $appMode, array $argv = null)
{
parent::__construct($argv);
$this->appMode = $appMode;
}
protected function doExecute()
{
$a = \Friendica\BaseObject::getApp();
if ($this->getOption('v')) {
$this->out('Executable: ' . $this->executable);
$this->out('Class: ' . __CLASS__);
@ -65,7 +75,7 @@ HELP;
$this->out('Options: ' . var_export($this->options, true));
}
if ($a->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
if (!$this->appMode->has(App\Mode::DBCONFIGAVAILABLE)) {
$this->out('Database isn\'t ready or populated yet, database cache won\'t be available');
}