Add task repository as a service

This commit is contained in:
Romain Neutron
2014-02-27 17:04:49 +01:00
parent 8f87e8b1c8
commit 0e95357060
5 changed files with 7 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ class TaskList extends Command
{
$output->writeln("<info>Querying the task manager...</info>");
$errors = 0;
$tasks = $this->container['manipulator.task']->getRepository()->findAll();
$tasks = $this->container['repo.tasks']->findAll();
$infos = $this->container['task-manager.live-information']->getTasks($tasks);
$rows = [];

View File

@@ -45,7 +45,7 @@ class TaskRun extends Command
{
declare(ticks=1);
if (null === $task = $this->container['manipulator.task']->getRepository()->find($input->getArgument('task_id'))) {
if (null === $task = $this->container['repo.tasks']->find($input->getArgument('task_id'))) {
throw new RuntimeException('Invalid task_id');
}

View File

@@ -32,7 +32,7 @@ class TaskState extends Command
protected function doExecute(InputInterface $input, OutputInterface $output)
{
$task_id = $input->getArgument('task_id');
if (null === $task = $this->container['manipulator.task']->getRepository()->find($task_id)) {
if (null === $task = $this->container['repo.tasks']->find($task_id)) {
throw new RuntimeException('Invalid task_id');
}

View File

@@ -146,7 +146,7 @@ class TaskManager implements ControllerProviderInterface
{
$tasks = [];
foreach ($app['manipulator.task']->getRepository()->findAll() as $task) {
foreach ($app['repo.tasks']->findAll() as $task) {
$tasks[] = array_replace(
$app['task-manager.live-information']->getTask($task), [
'id' => $task->getId(),

View File

@@ -187,6 +187,9 @@ class ORMServiceProvider implements ServiceProviderInterface
$app['repo.users'] = $app->share(function (PhraseaApplication $app) {
return $app['EM']->getRepository('Phraseanet:User');
});
$app['repo.tasks'] = $app->share(function (PhraseaApplication $app) {
return $app['EM']->getRepository('Phraseanet:Task');
});
}
public function boot(Application $app)