File events refactoring
This commit is contained in:
@@ -12,28 +12,4 @@ use Kanboard\Core\Base;
|
||||
*/
|
||||
class BaseSubscriber extends Base
|
||||
{
|
||||
/**
|
||||
* Method called
|
||||
*
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private $called = array();
|
||||
|
||||
/**
|
||||
* Check if a listener has been executed
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function isExecuted($key = '')
|
||||
{
|
||||
if (isset($this->called[$key])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->called[$key] = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,12 +36,10 @@ class NotificationSubscriber extends BaseSubscriber implements EventSubscriberIn
|
||||
|
||||
public function handleEvent(GenericEvent $event, $eventName)
|
||||
{
|
||||
if (!$this->isExecuted($eventName)) {
|
||||
$this->logger->debug('Subscriber executed: ' . __METHOD__);
|
||||
$this->logger->debug('Subscriber executed: ' . __METHOD__);
|
||||
|
||||
$this->queueManager->push(NotificationJob::getInstance($this->container)
|
||||
->withParams($event, $eventName, get_class($event))
|
||||
);
|
||||
}
|
||||
$this->queueManager->push(NotificationJob::getInstance($this->container)
|
||||
->withParams($event, $eventName, get_class($event))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class ProjectDailySummarySubscriber extends BaseSubscriber implements EventSubsc
|
||||
|
||||
public function execute(TaskEvent $event)
|
||||
{
|
||||
if (isset($event['project_id']) && !$this->isExecuted()) {
|
||||
if (isset($event['project_id'])) {
|
||||
$this->logger->debug('Subscriber executed: '.__METHOD__);
|
||||
$this->queueManager->push(ProjectMetricJob::getInstance($this->container)->withParams($event['project_id']));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class ProjectModificationDateSubscriber extends BaseSubscriber implements EventS
|
||||
|
||||
public function execute(GenericEvent $event)
|
||||
{
|
||||
if (isset($event['project_id']) && !$this->isExecuted()) {
|
||||
if (isset($event['project_id'])) {
|
||||
$this->logger->debug('Subscriber executed: '.__METHOD__);
|
||||
$this->projectModel->updateModificationDate($event['project_id']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user