Skip to content

Commit

Permalink
Merge pull request #1 from martinlutter/handle-callback
Browse files Browse the repository at this point in the history
use session values instead of empty attr
  • Loading branch information
ivanbarlog authored Oct 23, 2017
2 parents 1d6c9f5 + 1953010 commit 8399988
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 8399988

Please sign in to comment.