[ticket/11998] Add phpBB abstraction for application and command.

PHPBB3-11998
This commit is contained in:
Andreas Fischer 2013-11-05 19:42:34 +01:00
parent 6bd2a89efc
commit 73ea5daf97
4 changed files with 40 additions and 9 deletions

View file

@ -7,8 +7,6 @@
* *
*/ */
use Symfony\Component\Console\Application;
if (php_sapi_name() != 'cli') if (php_sapi_name() != 'cli')
{ {
echo 'This program must be run from the command line.' . PHP_EOL; echo 'This program must be run from the command line.' . PHP_EOL;
@ -32,9 +30,6 @@ $phpbb_class_loader_ext->register();
$phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, "$phpbb_root_path/config"); $phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, "$phpbb_root_path/config");
$application = new Application('phpBB Console', PHPBB_VERSION); $application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION);
foreach($phpbb_container->findTaggedServiceIds('console.command') as $id => $void) $application->register_container_commands($phpbb_container);
{
$application->add($phpbb_container->get($id));
}
$application->run(); $application->run();

View file

@ -0,0 +1,23 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\console;
use Symfony\Component\DependencyInjection\TaggedContainerInterface;
class application extends \Symfony\Component\Console\Application
{
function register_container_commands(TaggedContainerInterface $container, $tag = 'console.command')
{
foreach($container->findTaggedServiceIds($tag) as $id => $void)
{
$this->add($container->get($id));
}
}
}

View file

@ -0,0 +1,14 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\console\command;
abstract class command extends \Symfony\Component\Console\Command\Command
{
}

View file

@ -8,11 +8,10 @@
*/ */
namespace phpbb\console\command\fixup; namespace phpbb\console\command\fixup;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
class recalculate_email_hash extends Command class recalculate_email_hash extends \phpbb\console\command\command
{ {
/** @var \phpbb\db\driver\driver */ /** @var \phpbb\db\driver\driver */
protected $db; protected $db;