From 6a7b8ec60f265413ca88878dba6180456257d370 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 16 Jan 2016 21:06:36 -0500 Subject: Make sure that some event subscribers are not executed multiple times --- .../ProjectModificationDateSubscriber.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'app/Subscriber/ProjectModificationDateSubscriber.php') diff --git a/app/Subscriber/ProjectModificationDateSubscriber.php b/app/Subscriber/ProjectModificationDateSubscriber.php index 1f99840d..ea102910 100644 --- a/app/Subscriber/ProjectModificationDateSubscriber.php +++ b/app/Subscriber/ProjectModificationDateSubscriber.php @@ -6,25 +6,26 @@ use Kanboard\Event\GenericEvent; use Kanboard\Model\Task; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -class ProjectModificationDateSubscriber extends \Kanboard\Core\Base implements EventSubscriberInterface +class ProjectModificationDateSubscriber extends BaseSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents() { return array( - Task::EVENT_CREATE_UPDATE => array('execute', 0), - Task::EVENT_CLOSE => array('execute', 0), - Task::EVENT_OPEN => array('execute', 0), - Task::EVENT_MOVE_SWIMLANE => array('execute', 0), - Task::EVENT_MOVE_COLUMN => array('execute', 0), - Task::EVENT_MOVE_POSITION => array('execute', 0), - Task::EVENT_MOVE_PROJECT => array('execute', 0), - Task::EVENT_ASSIGNEE_CHANGE => array('execute', 0), + Task::EVENT_CREATE_UPDATE => 'execute', + Task::EVENT_CLOSE => 'execute', + Task::EVENT_OPEN => 'execute', + Task::EVENT_MOVE_SWIMLANE => 'execute', + Task::EVENT_MOVE_COLUMN => 'execute', + Task::EVENT_MOVE_POSITION => 'execute', + Task::EVENT_MOVE_PROJECT => 'execute', + Task::EVENT_ASSIGNEE_CHANGE => 'execute', ); } public function execute(GenericEvent $event) { - if (isset($event['project_id'])) { + if (isset($event['project_id']) && !$this->isExecuted()) { + $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); $this->project->updateModificationDate($event['project_id']); } } -- cgit v1.2.3