17 private $handlers = array();
31 $this->logger = $logger;
44 if (empty(
$name) || empty(
$type) || !is_callable($callback,
true)) {
48 if (!isset($this->handlers[
$name])) {
49 $this->handlers[
$name] = array();
52 if (!isset($this->handlers[$name][
$type])) {
59 while (isset($this->handlers[$name][$type][$priority])) {
64 ksort($this->handlers[$name][$type]);
80 if (isset($this->handlers[
$name]) && isset($this->handlers[$name][
$type])) {
81 $matcher = $this->getMatcher($callback);
83 foreach ($this->handlers[$name][$type] as
$key =>
$handler) {
94 unset($this->handlers[$name][$type][
$key]);
114 return $this->handlers;
142 if (
$name !=
'all' && $type !=
'all') {
143 $handlers = array_merge($handlers, array_values($this->handlers[
$name][$type]));
146 if (isset($this->handlers[
'all'][$type])) {
147 if ($type !=
'all') {
148 $handlers = array_merge($handlers, array_values($this->handlers[
'all'][$type]));
151 if (isset($this->handlers[
$name][
'all'])) {
152 if ($name !=
'all') {
153 $handlers = array_merge($handlers, array_values($this->handlers[$name][
'all']));
156 if (isset($this->handlers[
'all'][
'all'])) {
157 $handlers = array_merge($handlers, array_values($this->handlers[
'all'][
'all']));
171 if (is_string($spec) &&
false !== strpos($spec,
'::')) {
176 if (!is_array($spec) || empty($spec[0]) || empty($spec[1]) || !is_string($spec[1])) {
180 if (is_object($spec[0])) {
181 $spec[0] = get_class($spec[0]);
184 if (!is_string($spec[0])) {
hasHandler($name, $type)
Does the hook have a handler?
setLogger(\Elgg\Logger $logger=null)
Set a logger instance, e.g.
if($guid==elgg_get_logged_in_user_guid()) $name
registerHandler($name, $type, $callback, $priority=500)
Registers a handler.
Identify a static/dynamic method callable, even if contains an object to which you don't have a refer...
getMatcher($spec)
Create a matcher for the given callable (if it's for a static or dynamic method)
getAllHandlers()
Returns all registered handlers as array( $name => array( $type => array( $priority => callback...
unregisterHandler($name, $type, $callback)
Unregister a handler.
getOrderedHandlers($name, $type)
Returns an ordered array of handlers registered for $name and $type.