From 00294e3dae2840fa01acaf47db4e14ae08c0720a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Nov 2013 21:40:42 +0100 Subject: [ticket/11998] Turn develop/extensions.php into console commands. PHPBB3-11998 --- phpBB/phpbb/console/command/extension/command.php | 22 +++++++++ phpBB/phpbb/console/command/extension/disable.php | 47 ++++++++++++++++++ phpBB/phpbb/console/command/extension/enable.php | 47 ++++++++++++++++++ phpBB/phpbb/console/command/extension/purge.php | 47 ++++++++++++++++++ phpBB/phpbb/console/command/extension/show.php | 58 +++++++++++++++++++++++ 5 files changed, 221 insertions(+) create mode 100644 phpBB/phpbb/console/command/extension/command.php create mode 100644 phpBB/phpbb/console/command/extension/disable.php create mode 100644 phpBB/phpbb/console/command/extension/enable.php create mode 100644 phpBB/phpbb/console/command/extension/purge.php create mode 100644 phpBB/phpbb/console/command/extension/show.php (limited to 'phpBB/phpbb/console/command') diff --git a/phpBB/phpbb/console/command/extension/command.php b/phpBB/phpbb/console/command/extension/command.php new file mode 100644 index 0000000000..edde7ce2e2 --- /dev/null +++ b/phpBB/phpbb/console/command/extension/command.php @@ -0,0 +1,22 @@ +manager = $manager; + + parent::__construct(); + } +} diff --git a/phpBB/phpbb/console/command/extension/disable.php b/phpBB/phpbb/console/command/extension/disable.php new file mode 100644 index 0000000000..e4de70ca34 --- /dev/null +++ b/phpBB/phpbb/console/command/extension/disable.php @@ -0,0 +1,47 @@ +setName('extension:disable') + ->setDescription('Disables the specified extension.') + ->addArgument( + 'extension-name', + InputArgument::REQUIRED, + 'Name of the extension' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $name = $input->getArgument('extension-name'); + $this->manager->disable($name); + $this->manager->load_extensions(); + + if ($this->manager->enabled($name)) + { + $output->writeln("Could not disable extension $name"); + return 1; + } + else + { + $output->writeln("Successfully disabled extension $name"); + return 0; + } + } +} diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php new file mode 100644 index 0000000000..ee7dae76aa --- /dev/null +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -0,0 +1,47 @@ +setName('extension:enable') + ->setDescription('Enables the specified extension.') + ->addArgument( + 'extension-name', + InputArgument::REQUIRED, + 'Name of the extension' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $name = $input->getArgument('extension-name'); + $this->manager->enable($name); + $this->manager->load_extensions(); + + if ($this->manager->enabled($name)) + { + $output->writeln("Successfully enabled extension $name"); + return 0; + } + else + { + $output->writeln("Could not enable extension $name"); + return 1; + } + } +} diff --git a/phpBB/phpbb/console/command/extension/purge.php b/phpBB/phpbb/console/command/extension/purge.php new file mode 100644 index 0000000000..c2e1d2928c --- /dev/null +++ b/phpBB/phpbb/console/command/extension/purge.php @@ -0,0 +1,47 @@ +setName('extension:purge') + ->setDescription('Purges the specified extension.') + ->addArgument( + 'extension-name', + InputArgument::REQUIRED, + 'Name of the extension' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $name = $input->getArgument('extension-name'); + $this->manager->purge($name); + $this->manager->load_extensions(); + + if ($this->manager->enabled($name)) + { + $output->writeln("Could not purge extension $name"); + return 1; + } + else + { + $output->writeln("Successfully purge extension $name"); + return 0; + } + } +} diff --git a/phpBB/phpbb/console/command/extension/show.php b/phpBB/phpbb/console/command/extension/show.php new file mode 100644 index 0000000000..0f48ac2379 --- /dev/null +++ b/phpBB/phpbb/console/command/extension/show.php @@ -0,0 +1,58 @@ +setName('extension:show') + ->setDescription('Lists all extensions in the database and on the filesystem.') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->manager->load_extensions(); + $all = array_keys($this->manager->all_available()); + + if (empty($all)) + { + $output->writeln('No extensions were found.'); + return 3; + } + + $enabled = array_keys($this->manager->all_enabled()); + $this->print_extension_list($output, 'Enabled', $enabled); + + $output->writeln(''); + + $disabled = array_keys($this->manager->all_disabled()); + $this->print_extension_list($output, 'Disabled', $disabled); + + $output->writeln(''); + + $purged = array_diff($all, $enabled, $disabled); + $this->print_extension_list($output, 'Available', $purged); + } + + protected function print_extension_list(OutputInterface $output, $type, array $extensions) + { + $output->writeln("$type:"); + + foreach ($extensions as $extension) + { + $output->writeln(" - $extension"); + } + } +} -- cgit v1.2.1