Fix priority of Filters API

This commit is contained in:
Pig Fang 2019-09-04 19:33:39 +08:00
parent 3fc176e07a
commit 9402f5f83e
2 changed files with 2 additions and 2 deletions

View File

@ -27,7 +27,7 @@ class Filter
$listeners = $this->getListeners($hook);
if ($listeners->isNotEmpty()) {
return $this->listeners[$hook]
->sortByDesc('priority')
->sortBy('priority')
->reduce(function ($carry, $item) use ($args) {
return call_user_func($item['callback'], $carry, ...$args);
}, $init);

View File

@ -29,7 +29,7 @@ class FilterTest extends TestCase
$filter->add('hook', function ($value) {
return $value.'_high';
}, 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()