tormjens / eventy

WordPress-like actions and filters for Laravel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When 2 or more actions have the same priority, just one registered

midoalone opened this issue · comments

When I tried to register more than one action with the same priority, just on of them "The last one" is registered and override the others.

Sorry for the late response. I'll have a look at it ASAP!

commented

Was this ever fixed?

unfortunately this bug has not beed fixed yet

I have fixed this issue with some tricks by changing listen function
file Event.php
public function listen($hook, $callback, $priority = 20, $arguments = 1) { $i = 0; $uniquePriority = $priority; do { if( isset( $this->listeners[$uniquePriority][$hook] ) ) { $i += 0.1; $uniquePriority = $priority + $i; } } while( isset( $this->listeners[$uniquePriority][$hook] ) ); $this->listeners[$uniquePriority][$hook] = compact('callback', 'arguments'); }

Great stuff! Thanks.