mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
45 lines
975 B
PHP
45 lines
975 B
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\TaskManager\Event;
|
|
|
|
use Doctrine\Common\Persistence\ObjectManager;
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
|
|
/**
|
|
* Removes a task from ObjectManager once the JobEvents::FINISHED is triggered.
|
|
*/
|
|
class FinishedJobRemoverSubscriber implements EventSubscriberInterface
|
|
{
|
|
private $om;
|
|
|
|
public function __construct(ObjectManager $om)
|
|
{
|
|
$this->om = $om;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static function getSubscribedEvents()
|
|
{
|
|
return array(
|
|
JobEvents::FINISHED => array($this, 'onJobFinish'),
|
|
);
|
|
}
|
|
|
|
public function onJobFinish(JobFinishedEvent $event)
|
|
{
|
|
$this->om->remove($event->getTask());
|
|
$this->om->flush();
|
|
}
|
|
}
|