X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FConsole.php;h=28bf8523dc8ad3cd92af27c31b5b1c2324eab5b9;hb=44291a465bb9b9c54b8781d6d6f13e1c3f317c1b;hp=29ccd795b826078fcc1c85035d81d1458eeade71;hpb=3dfb0c2e7cc84dc7e43a975f44e8854b98d043bc;p=friendica.git diff --git a/src/Core/Console.php b/src/Core/Console.php index 29ccd795b8..28bf8523dc 100644 --- a/src/Core/Console.php +++ b/src/Core/Console.php @@ -1,11 +1,31 @@ . + * + */ namespace Friendica\Core; +use Dice\Dice; +use Friendica; + /** * Description of Console - * - * @author Hypolite Petovan */ class Console extends \Asika\SimpleConsole\Console { @@ -13,23 +33,10 @@ class Console extends \Asika\SimpleConsole\Console protected $helpOptions = []; protected $customHelpOptions = ['h', 'help', '?']; - protected $subConsoles = [ - 'config' => __NAMESPACE__ . '\Console\Config', - 'createdoxygen' => __NAMESPACE__ . '\Console\CreateDoxygen', - 'docbloxerrorchecker' => __NAMESPACE__ . '\Console\DocBloxErrorChecker', - 'dbstructure' => __NAMESPACE__ . '\Console\DatabaseStructure', - 'extract' => __NAMESPACE__ . '\Console\Extract', - 'globalcommunityblock' => __NAMESPACE__ . '\Console\GlobalCommunityBlock', - 'globalcommunitysilence' => __NAMESPACE__ . '\Console\GlobalCommunitySilence', - 'archivecontact' => __NAMESPACE__ . '\Console\ArchiveContact', - 'autoinstall' => __NAMESPACE__ . '\Console\AutomaticInstallation', - 'maintenance' => __NAMESPACE__ . '\Console\Maintenance', - 'newpassword' => __NAMESPACE__ . '\Console\NewPassword', - 'php2po' => __NAMESPACE__ . '\Console\PhpToPo', - 'po2php' => __NAMESPACE__ . '\Console\PoToPhp', - 'typo' => __NAMESPACE__ . '\Console\Typo', - 'postupdate' => __NAMESPACE__ . '\Console\PostUpdate', - ]; + /** + * @var Dice The DI library + */ + protected $dice; protected function getHelp() { @@ -37,22 +44,29 @@ class Console extends \Asika\SimpleConsole\Console Usage: bin/console [--version] [-h|--help|-?] [] [-v] Commands: + addon Addon management + cache Manage node cache config Edit site config + contact Contact management createdoxygen Generate Doxygen headers dbstructure Do database updates docbloxerrorchecker Check the file tree for DocBlox errors extract Generate translation string file for the Friendica project (deprecated) globalcommunityblock Block remote profile from interacting with this node - globalcommunitysilence Silence remote profile from global community page + globalcommunitysilence Silence a profile from the global community page archivecontact Archive a contact when you know that it isn't existing anymore help Show help about a command, e.g (bin/console help config) autoinstall Starts automatic installation of friendica based on values from htconfig.php + lock Edit site locks maintenance Set maintenance mode for this node - newpassword Set a new password for a given user + user User management php2po Generate a messages.po file from a strings.php file po2php Generate a strings.php file from a messages.po file typo Checks for parse errors in Friendica files postupdate Execute pending post update scripts (can last days) + serverblock Manage blocked servers + storage Manage storage backend + relay Manage ActivityPub relay servers Options: -h|--help|-? Show help information @@ -61,6 +75,46 @@ HELP; return $help; } + protected $subConsoles = [ + 'addon' => Friendica\Console\Addon::class, + 'archivecontact' => Friendica\Console\ArchiveContact::class, + 'autoinstall' => Friendica\Console\AutomaticInstallation::class, + 'cache' => Friendica\Console\Cache::class, + 'config' => Friendica\Console\Config::class, + 'contact' => Friendica\Console\Contact::class, + 'createdoxygen' => Friendica\Console\CreateDoxygen::class, + 'docbloxerrorchecker' => Friendica\Console\DocBloxErrorChecker::class, + 'dbstructure' => Friendica\Console\DatabaseStructure::class, + 'extract' => Friendica\Console\Extract::class, + 'fixapdeliveryworkertaskparameters' => Friendica\Console\FixAPDeliveryWorkerTaskParameters::class, + 'globalcommunityblock' => Friendica\Console\GlobalCommunityBlock::class, + 'globalcommunitysilence' => Friendica\Console\GlobalCommunitySilence::class, + 'lock' => Friendica\Console\Lock::class, + 'maintenance' => Friendica\Console\Maintenance::class, + 'php2po' => Friendica\Console\PhpToPo::class, + 'postupdate' => Friendica\Console\PostUpdate::class, + 'po2php' => Friendica\Console\PoToPhp::class, + 'relay' => Friendica\Console\Relay::class, + 'serverblock' => Friendica\Console\ServerBlock::class, + 'storage' => Friendica\Console\Storage::class, + 'test' => Friendica\Console\Test::class, + 'typo' => Friendica\Console\Typo::class, + 'user' => Friendica\Console\User::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')) { @@ -69,7 +123,6 @@ HELP; $this->out('Options: ' . var_export($this->options, true)); } - $showHelp = false; $subHelp = false; $command = null; @@ -79,7 +132,6 @@ HELP; return 0; } elseif ((count($this->options) === 0 || $this->getOption($this->customHelpOptions) === true || $this->getOption($this->customHelpOptions) === 1) && count($this->args) === 0 ) { - $showHelp = true; } elseif (count($this->args) >= 2 && $this->getArgument(0) == 'help') { $command = $this->getArgument(1); $subHelp = true; @@ -119,7 +171,12 @@ HELP; $className = $this->subConsoles[$command]; - $subconsole = new $className($subargs); + Friendica\DI::init($this->dice); + + Renderer::registerTemplateEngine('Friendica\Render\FriendicaSmartyEngine'); + + /** @var Console $subconsole */ + $subconsole = $this->dice->create($className, [$subargs]); foreach ($this->options as $name => $value) { $subconsole->setOption($name, $value);