Skip to content

Commit

Permalink
revt toorig
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jun 14, 2020
1 parent 4766d2f commit 0a8668a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/HookTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,15 @@ public function hook(string $spot, array $args = [], HookBreaker &$brokenBy = nu

$return = [];
if (isset($this->hooks[$spot])) {
ksort($this->hooks[$spot]); // lower priority is called sooner
krsort($this->hooks[$spot]); // lower priority is called sooner
$hookBackup = $this->hooks[$spot];

try {
$bb = $this->_hookActiveSpots[$spot] ?? false;
$this->_hookActiveSpots[$spot] = true;

foreach ($this->hooks[$spot] as $datas) {
foreach ($datas as $index => $data) {
while ($_data = array_pop($this->hooks[$spot])) {
foreach ($_data as $index => $data) {
$return[$index] = $data[0](...array_merge(
[$this],
$args,
Expand All @@ -155,7 +157,8 @@ public function hook(string $spot, array $args = [], HookBreaker &$brokenBy = nu

return $e->getReturnValue();
} finally {
$this->_hookActiveSpots[$spot] = false;
$this->hooks[$spot] = $hookBackup;
$this->_hookActiveSpots[$spot] = $bb;
}
}

Expand Down

0 comments on commit 0a8668a

Please sign in to comment.