Skip to content

Commit

Permalink
use session values instead of empty attr
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlutter committed Oct 23, 2017
1 parent f956f94 commit 1953010
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Handler/Callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class Callbacks

/** @var Session */
private $session;
/** @var AjaxCallback[] */
private $callbacks = [];

public function __construct(Session $session)
{
Expand All @@ -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;
}

Expand Down

0 comments on commit 1953010

Please sign in to comment.