From 1953010e54cd32540856d286f49c4d862c567e25 Mon Sep 17 00:00:00 2001 From: martinlutter Date: Mon, 23 Oct 2017 12:19:35 +0200 Subject: [PATCH] use session values instead of empty attr --- src/Handler/Callbacks.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Handler/Callbacks.php b/src/Handler/Callbacks.php index 07f7ee3..a7d978d 100644 --- a/src/Handler/Callbacks.php +++ b/src/Handler/Callbacks.php @@ -19,8 +19,6 @@ class Callbacks /** @var Session */ private $session; - /** @var AjaxCallback[] */ - private $callbacks = []; public function __construct(Session $session) { @@ -29,11 +27,16 @@ public function __construct(Session $session) public function handle(Handler $ajax): Handler { - uasort($this->callbacks, [$this, 'sortByPriority']); - foreach ($this->callbacks as $callback) { + /** @var AjaxCallback[] $callbacks */ + $callbacks = $this->session->get(self::SESSION_KEY, []); + uasort($callbacks, [$this, 'sortByPriority']); + + foreach ($callbacks as $callback) { $ajax->callback($callback->getFunction(), $callback->getParameters()); } + $this->session->remove(self::SESSION_KEY); + return $ajax; }