| @@ 30-37 (lines=8) @@ | ||
| 27 | static::$_modders[$name] = [$modder]; |
|
| 28 | } |
|
| 29 | ||
| 30 | public static function remove($name,callable $modder = null){ |
|
| 31 | if($modder === null) { |
|
| 32 | unset(static::$_modders[$name]); |
|
| 33 | } else { |
|
| 34 | if ($idx = array_search($modder,static::$_modders[$name],true)) |
|
| 35 | unset(static::$_modders[$name][$idx]); |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| 39 | public static function with($names, $default, ...$args){ |
|
| 40 | foreach ((array)$names as $name) { |
|
| @@ 25-32 (lines=8) @@ | ||
| 22 | static::$_listeners[$name] = [$listener]; |
|
| 23 | } |
|
| 24 | ||
| 25 | public static function off($name,callable $listener = null){ |
|
| 26 | if($listener === null) { |
|
| 27 | unset(static::$_listeners[$name]); |
|
| 28 | } else { |
|
| 29 | if ($idx = array_search($listener,static::$_listeners[$name],true)) |
|
| 30 | unset(static::$_listeners[$name][$idx]); |
|
| 31 | } |
|
| 32 | } |
|
| 33 | ||
| 34 | public static function alias($source,$alias){ |
|
| 35 | static::$_listeners[$alias] =& static::$_listeners[$source]; |
|