summaryrefslogtreecommitdiff
path: root/app/Subscriber/BaseSubscriber.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-16 21:06:36 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-16 21:06:36 -0500
commit6a7b8ec60f265413ca88878dba6180456257d370 (patch)
tree5b36bf3122d6884cb09b66e623e28768e92ed9ba /app/Subscriber/BaseSubscriber.php
parent6a0895ef765ea7b83df02bb9789fda7415dee9a5 (diff)
Make sure that some event subscribers are not executed multiple times
Diffstat (limited to 'app/Subscriber/BaseSubscriber.php')
-rw-r--r--app/Subscriber/BaseSubscriber.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/app/Subscriber/BaseSubscriber.php b/app/Subscriber/BaseSubscriber.php
new file mode 100644
index 00000000..875c5e26
--- /dev/null
+++ b/app/Subscriber/BaseSubscriber.php
@@ -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;
+ }
+}