mirror of
https://github.com/friendica/friendica
synced 2025-04-25 18:30: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,6 +2,7 @@
|
|||
|
||||
namespace Friendica\Core;
|
||||
|
||||
use Dice\Dice;
|
||||
use Friendica;
|
||||
|
||||
/**
|
||||
|
@ -15,6 +16,11 @@ class Console extends \Asika\SimpleConsole\Console
|
|||
protected $helpOptions = [];
|
||||
protected $customHelpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var Dice The DI library
|
||||
*/
|
||||
protected $dice;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -69,6 +75,19 @@ HELP;
|
|||
'storage' => Friendica\Console\Storage::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* CliInput Friendica constructor.
|
||||
*
|
||||
* @param Dice $dice The DI library
|
||||
* @param array $argv
|
||||
*/
|
||||
public function __construct(Dice $dice, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->dice = $dice;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
if ($this->getOption('v')) {
|
||||
|
@ -125,8 +144,10 @@ HELP;
|
|||
|
||||
$className = $this->subConsoles[$command];
|
||||
|
||||
Friendica\BaseObject::setDependencyInjection($this->dice);
|
||||
|
||||
/** @var Console $subconsole */
|
||||
$subconsole = new $className($subargs);
|
||||
$subconsole = $this->dice->create($className, [$subargs]);
|
||||
|
||||
foreach ($this->options as $name => $value) {
|
||||
$subconsole->setOption($name, $value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue