summaryrefslogtreecommitdiff
path: root/app/Action/Base.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-12-27 19:10:38 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-12-27 19:10:38 -0500
commit17dc5bdc9ede52ad618bbf326e67e3b6988170f7 (patch)
tree9cf4d325667f11fa735bca84042fb385e3273329 /app/Action/Base.php
parentcf821e117ce8b937cff7f386a107aaa81ba6bf9b (diff)
Move events handling to Symfony\EventDispatcher
Diffstat (limited to 'app/Action/Base.php')
-rw-r--r--app/Action/Base.php30
1 files changed, 23 insertions, 7 deletions
diff --git a/app/Action/Base.php b/app/Action/Base.php
index a2b07e3f..70dd871d 100644
--- a/app/Action/Base.php
+++ b/app/Action/Base.php
@@ -2,9 +2,8 @@
namespace Action;
+use Event\GenericEvent;
use Pimple\Container;
-use Core\Listener;
-use Core\Tool;
/**
* Base class for automatic actions
@@ -21,9 +20,17 @@ use Core\Tool;
* @property \Model\TaskFinder $taskFinder
* @property \Model\TaskStatus $taskStatus
*/
-abstract class Base implements Listener
+abstract class Base
{
/**
+ * Flag for called listener
+ *
+ * @access private
+ * @var boolean
+ */
+ private $called = false;
+
+ /**
* Project id
*
* @access private
@@ -114,6 +121,7 @@ abstract class Base implements Listener
$this->container = $container;
$this->project_id = $project_id;
$this->event_name = $event_name;
+ $this->called = false;
}
/**
@@ -136,7 +144,7 @@ abstract class Base implements Listener
*/
public function __get($name)
{
- return Tool::loadModel($this->container, $name);
+ return $this->container[$name];
}
/**
@@ -225,12 +233,20 @@ abstract class Base implements Listener
* Execute the action
*
* @access public
- * @param array $data Event data dictionary
- * @return bool True if the action was executed or false when not executed
+ * @param \Event\GenericEvent $event Event data dictionary
+ * @return bool True if the action was executed or false when not executed
*/
- public function execute(array $data)
+ public function execute(GenericEvent $event)
{
+ // Avoid infinite loop, a listener instance can be called only one time
+ if ($this->called) {
+ return false;
+ }
+
+ $data = $event->getAll();
+
if ($this->isExecutable($data)) {
+ $this->called = true;
return $this->doAction($data);
}