Fix priority of Filters API
This commit is contained in:
parent
3fc176e07a
commit
9402f5f83e
@ -27,7 +27,7 @@ class Filter
|
|||||||
$listeners = $this->getListeners($hook);
|
$listeners = $this->getListeners($hook);
|
||||||
if ($listeners->isNotEmpty()) {
|
if ($listeners->isNotEmpty()) {
|
||||||
return $this->listeners[$hook]
|
return $this->listeners[$hook]
|
||||||
->sortByDesc('priority')
|
->sortBy('priority')
|
||||||
->reduce(function ($carry, $item) use ($args) {
|
->reduce(function ($carry, $item) use ($args) {
|
||||||
return call_user_func($item['callback'], $carry, ...$args);
|
return call_user_func($item['callback'], $carry, ...$args);
|
||||||
}, $init);
|
}, $init);
|
||||||
|
@ -29,7 +29,7 @@ class FilterTest extends TestCase
|
|||||||
$filter->add('hook', function ($value) {
|
$filter->add('hook', function ($value) {
|
||||||
return $value.'_high';
|
return $value.'_high';
|
||||||
}, 30);
|
}, 30);
|
||||||
$this->assertEquals('value_high_medium_low', $filter->apply('hook', 'value', ['add']));
|
$this->assertEquals('value_low_medium_high', $filter->apply('hook', 'value', ['add']));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemove()
|
public function testRemove()
|
||||||
|
Loading…
Reference in New Issue
Block a user