Files
Phraseanet/lib/Alchemy/Phrasea/CLI.php
Romain Neutron ea7523f1db Merge branch '3.8'
Conflicts:
	lib/Alchemy/Phrasea/Controller/Admin/Publications.php
	lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php
	lib/Alchemy/Phrasea/Controller/Api/V1.php
	lib/Alchemy/Phrasea/Controller/Lightbox.php
	lib/Alchemy/Phrasea/Controller/Permalink.php
	lib/Alchemy/Phrasea/Controller/Prod/Feed.php
	lib/Alchemy/Phrasea/Controller/Prod/Order.php
	lib/Alchemy/Phrasea/Controller/Prod/Push.php
	lib/Alchemy/Phrasea/Controller/Prod/Share.php
	lib/Alchemy/Phrasea/Controller/Root/Login.php
	lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php
	lib/Alchemy/Phrasea/Controller/Root/Session.php
	lib/Alchemy/Phrasea/Controller/Setup.php
	lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php
	lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php
	lib/Alchemy/Phrasea/Core/Provider/TaskManagerServiceProvider.php
	lib/classes/Feed/Entry/Item.php
	lib/classes/record/adapter.php
	lib/classes/task/Scheduler.php
	lib/classes/task/manager.php
	lib/classes/task/period/RecordMover.php
	lib/classes/task/period/archive.php
	lib/classes/task/period/cindexer.php
	lib/classes/task/period/ftp.php
	lib/classes/task/period/ftpPull.php
	lib/classes/task/period/subdef.php
	lib/classes/task/period/writemeta.php
	tests/Alchemy/Tests/Phrasea/Border/ManagerTest.php
	tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php
	tests/classes/Feed/Entry/Feed_Entry_ItemTest.php
	tests/classes/PhraseanetPHPUnitAbstract.php
2013-10-31 14:01:44 +01:00

110 lines
3.0 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea;
use Alchemy\Phrasea\Command\CommandInterface;
use Symfony\Component\Console;
use Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider;
use Alchemy\Phrasea\Core\CLIProvider\ComposerSetupServiceProvider;
use Alchemy\Phrasea\Core\CLIProvider\LessBuilderServiceProvider;
use Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider;
use Alchemy\Phrasea\Core\CLIProvider\SignalHandlerServiceProvider;
use Alchemy\Phrasea\Core\CLIProvider\TaskManagerServiceProvider;
/**
* Phraseanet Command Line Application
*
* Largely inspired by Cilex
* @see https://github.com/Cilex/Cilex
*/
class CLI extends Application
{
/**
* Registers the autoloader and necessary components.
*
* @param string $name Name for this application.
* @param string|null $version Version number for this application.
* @param string|null $environment The environment.
*/
public function __construct($name, $version = null, $environment = null)
{
parent::__construct($environment);
$app = $this;
$this['session.test'] = true;
$this['console'] = $this->share(function () use ($name, $version) {
return new Console\Application($name, $version);
});
$this['dispatcher']->addListener('phraseanet.notification.sent', function () use ($app) {
$app['swiftmailer.spooltransport']->getSpool()->flushQueue($app['swiftmailer.transport']);
});
$this->register(new PluginServiceProvider());
$this->register(new ComposerSetupServiceProvider());
$this->register(new CLIDriversServiceProvider());
$this->register(new LessBuilderServiceProvider());
$this->register(new SignalHandlerServiceProvider());
$this->register(new TaskManagerServiceProvider());
$this->bindRoutes();
}
/**
* Executes this application.
*
* @param bool $interactive runs in an interactive shell if true.
*/
public function runCLI($interactive = false)
{
$app = $this['console'];
if ($interactive) {
$app = new Console\Shell($app);
}
$app->run();
}
public function run(\Symfony\Component\HttpFoundation\Request $request = null)
{
$this->runCLI();
}
/**
* Adds a command object.
*
* If a command with the same name already exists, it will be overridden.
*
* @param CommandInterface $command A Command object
*/
public function command(CommandInterface $command)
{
$command->setContainer($this);
$this['console']->add($command);
}
/**
* {@inheritdoc}
*/
public function loadPlugins()
{
parent::loadPlugins();
call_user_func(function ($cli) {
require $cli['plugins.directory'] . '/commands.php';
}, $this);
}
}