Allow one call by event
This commit is contained in:
@@ -21,19 +21,19 @@ class BaseSubscriber extends Base
|
|||||||
private $called = array();
|
private $called = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a method has been executed
|
* Check if a listener has been executed
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $method
|
* @param string $key
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isExecuted($method = '')
|
public function isExecuted($key = '')
|
||||||
{
|
{
|
||||||
if (isset($this->called[$method])) {
|
if (isset($this->called[$key])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->called[$method] = true;
|
$this->called[$key] = true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class NotificationSubscriber extends BaseSubscriber implements EventSubscriberIn
|
|||||||
|
|
||||||
public function handleEvent(GenericEvent $event, $event_name)
|
public function handleEvent(GenericEvent $event, $event_name)
|
||||||
{
|
{
|
||||||
if (! $this->isExecuted()) {
|
if (! $this->isExecuted($event_name)) {
|
||||||
$this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__);
|
$this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__);
|
||||||
$event_data = $this->getEventData($event);
|
$event_data = $this->getEventData($event);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user