mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Update tasks service provider
This commit is contained in:
@@ -20,8 +20,10 @@ use Alchemy\Phrasea\TaskManager\Job\RecordMoverJob;
|
||||
use Alchemy\Phrasea\TaskManager\Job\SubdefsJob;
|
||||
use Alchemy\Phrasea\TaskManager\Job\WriteMetadataJob;
|
||||
use Alchemy\Phrasea\TaskManager\Job\Factory as JobFactory;
|
||||
use Alchemy\Phrasea\TaskManager\LiveInformation;
|
||||
use Alchemy\Phrasea\TaskManager\TaskManagerStatus;
|
||||
use Alchemy\Phrasea\TaskManager\Log\LogFileFactory;
|
||||
use Alchemy\Phrasea\TaskManager\Notifier;
|
||||
use Silex\Application;
|
||||
use Silex\ServiceProviderInterface;
|
||||
|
||||
@@ -29,6 +31,25 @@ class TasksServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Application $app)
|
||||
{
|
||||
$app['task-manager.notifier'] = $app->share(function(Application $app) {
|
||||
return Notifier::create($app['task-manager.listener.options']);
|
||||
});
|
||||
|
||||
$app['task-manager.listener.options'] = $app->share(function(Application $app) {
|
||||
if (isset($app['phraseanet.configuration']['task-manager']) && isset($app['phraseanet.configuration']['task-manager']['listener'])) {
|
||||
$listenerConf = $app['phraseanet.configuration']['task-manager']['listener'];
|
||||
} else {
|
||||
$listenerConf = array();
|
||||
}
|
||||
|
||||
return array_replace(array(
|
||||
'protocol' => 'tcp',
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 6660,
|
||||
'linger' => 500,
|
||||
), $listenerConf);
|
||||
});
|
||||
|
||||
$app['task-manager.job-factory'] = $app->share(function(Application $app) {
|
||||
return new JobFactory($app['dispatcher'],isset($app['task-manager.logger']) ? $app['task-manager.logger'] : $app['logger']);
|
||||
});
|
||||
@@ -37,6 +58,10 @@ class TasksServiceProvider implements ServiceProviderInterface
|
||||
return new TaskManagerStatus($app['phraseanet.configuration']);
|
||||
});
|
||||
|
||||
$app['task-manager.live-information'] = $app->share(function(Application $app) {
|
||||
return new LiveInformation($app['task-manager.status'], $app['task-manager.notifier']);
|
||||
});
|
||||
|
||||
$app['task-manager.log-file.root'] = $app->share(function (Application $app) {
|
||||
return $app['root.path'].'/logs';
|
||||
});
|
||||
|
@@ -25,6 +25,16 @@ class TasksServiceProviderTest extends ServiceProviderTestCase
|
||||
'task-manager.log-file.factory',
|
||||
'Alchemy\Phrasea\TaskManager\Log\LogFileFactory'
|
||||
),
|
||||
array(
|
||||
'Alchemy\Phrasea\Core\Provider\TasksServiceProvider',
|
||||
'task-manager.notifier',
|
||||
'Alchemy\Phrasea\TaskManager\Notifier'
|
||||
),
|
||||
array(
|
||||
'Alchemy\Phrasea\Core\Provider\TasksServiceProvider',
|
||||
'task-manager.live-information',
|
||||
'Alchemy\Phrasea\TaskManager\LiveInformation'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user