From fb642b76bb3d84b38c09f5d9dff8b51369eedaf2 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 29 May 2016 20:33:48 -0400 Subject: Make console commands pluggable --- app/Console/PluginInstallCommand.php | 3 +- app/Console/PluginUninstallCommand.php | 3 +- app/Console/PluginUpgradeCommand.php | 3 +- app/Core/Base.php | 1 + app/ServiceProvider/CommandProvider.php | 62 +++++++++++++++++++++++++++++++++ app/common.php | 1 + 6 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 app/ServiceProvider/CommandProvider.php (limited to 'app') diff --git a/app/Console/PluginInstallCommand.php b/app/Console/PluginInstallCommand.php index 1c6e14b3..a82f0069 100644 --- a/app/Console/PluginInstallCommand.php +++ b/app/Console/PluginInstallCommand.php @@ -4,6 +4,7 @@ namespace Kanboard\Console; use Kanboard\Core\Plugin\Installer; use Kanboard\Core\Plugin\PluginInstallerException; +use LogicException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -21,7 +22,7 @@ class PluginInstallCommand extends BaseCommand protected function execute(InputInterface $input, OutputInterface $output) { if (!Installer::isConfigured()) { - $output->writeln('Kanboard is not configured to install plugins itself'); + throw new LogicException('Kanboard is not configured to install plugins itself'); } try { diff --git a/app/Console/PluginUninstallCommand.php b/app/Console/PluginUninstallCommand.php index c645e03f..48722130 100644 --- a/app/Console/PluginUninstallCommand.php +++ b/app/Console/PluginUninstallCommand.php @@ -4,6 +4,7 @@ namespace Kanboard\Console; use Kanboard\Core\Plugin\Installer; use Kanboard\Core\Plugin\PluginInstallerException; +use LogicException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -21,7 +22,7 @@ class PluginUninstallCommand extends BaseCommand protected function execute(InputInterface $input, OutputInterface $output) { if (!Installer::isConfigured()) { - $output->writeln('Kanboard is not configured to remove plugins itself'); + throw new LogicException('Kanboard is not configured to install plugins itself'); } try { diff --git a/app/Console/PluginUpgradeCommand.php b/app/Console/PluginUpgradeCommand.php index 839124b1..6c66e917 100644 --- a/app/Console/PluginUpgradeCommand.php +++ b/app/Console/PluginUpgradeCommand.php @@ -5,6 +5,7 @@ namespace Kanboard\Console; use Kanboard\Core\Plugin\Base as BasePlugin; use Kanboard\Core\Plugin\Directory; use Kanboard\Core\Plugin\Installer; +use LogicException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -21,7 +22,7 @@ class PluginUpgradeCommand extends BaseCommand protected function execute(InputInterface $input, OutputInterface $output) { if (!Installer::isConfigured()) { - $output->writeln('Kanboard is not configured to upgrade plugins itself'); + throw new LogicException('Kanboard is not configured to install plugins itself'); } $installer = new Installer($this->container); diff --git a/app/Core/Base.php b/app/Core/Base.php index 725bd7c0..7b4462e2 100644 --- a/app/Core/Base.php +++ b/app/Core/Base.php @@ -140,6 +140,7 @@ use Pimple\Container; * @property \Psr\Log\LoggerInterface $logger * @property \PicoDb\Database $db * @property \Symfony\Component\EventDispatcher\EventDispatcher $dispatcher + * @property \Symfony\Component\Console\Application $cli * @property \JsonRPC\Server $api */ abstract class Base diff --git a/app/ServiceProvider/CommandProvider.php b/app/ServiceProvider/CommandProvider.php new file mode 100644 index 00000000..55c2712b --- /dev/null +++ b/app/ServiceProvider/CommandProvider.php @@ -0,0 +1,62 @@ +add(new TaskOverdueNotificationCommand($container)); + $application->add(new SubtaskExportCommand($container)); + $application->add(new TaskExportCommand($container)); + $application->add(new ProjectDailyStatsCalculationCommand($container)); + $application->add(new ProjectDailyColumnStatsExportCommand($container)); + $application->add(new TransitionExportCommand($container)); + $application->add(new LocaleSyncCommand($container)); + $application->add(new LocaleComparatorCommand($container)); + $application->add(new TaskTriggerCommand($container)); + $application->add(new CronjobCommand($container)); + $application->add(new WorkerCommand($container)); + $application->add(new ResetPasswordCommand($container)); + $application->add(new ResetTwoFactorCommand($container)); + $application->add(new PluginUpgradeCommand($container)); + $application->add(new PluginInstallCommand($container)); + $application->add(new PluginUninstallCommand($container)); + + $container['cli'] = $application; + return $container; + } +} diff --git a/app/common.php b/app/common.php index e73d3a64..72be3603 100644 --- a/app/common.php +++ b/app/common.php @@ -48,4 +48,5 @@ $container->register(new Kanboard\ServiceProvider\AvatarProvider()); $container->register(new Kanboard\ServiceProvider\FilterProvider()); $container->register(new Kanboard\ServiceProvider\QueueProvider()); $container->register(new Kanboard\ServiceProvider\ApiProvider()); +$container->register(new Kanboard\ServiceProvider\CommandProvider()); $container->register(new Kanboard\ServiceProvider\PluginProvider()); -- cgit v1.2.3