Make sure that some event subscribers are not executed multiple times

This commit is contained in:
Frederic Guillot
2016-01-16 21:06:36 -05:00
parent 6a0895ef76
commit 6a7b8ec60f
10 changed files with 95 additions and 39 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace Kanboard\Subscriber;
use Kanboard\Core\Base;
/**
* Base class for subscribers
*
* @package subscriber
* @author Frederic Guillot
*/
class BaseSubscriber extends Base
{
/**
* Method called
*
* @access private
* @var array
*/
private $called = array();
/**
* Check if a method has been executed
*
* @access public
* @param string $method
* @return boolean
*/
public function isExecuted($method = '')
{
if (isset($this->called[$method])) {
return true;
}
$this->called[$method] = true;
return false;
}
}