16 private $handlers = array();
43 if (empty(
$name) || empty(
$type) || !is_callable($callback,
true)) {
47 if (!isset($this->handlers[
$name])) {
48 $this->handlers[
$name] = array();
51 if (!isset($this->handlers[$name][
$type])) {
58 while (isset($this->handlers[$name][$type][$priority])) {
63 ksort($this->handlers[$name][$type]);
79 if (isset($this->handlers[
$name]) && isset($this->handlers[$name][
$type])) {
80 foreach ($this->handlers[$name][$type] as
$key => $name_callback) {
81 if ($name_callback == $callback) {
82 unset($this->handlers[$name][$type][
$key]);
103 return $this->handlers;
129 if (
$name !=
'all' && $type !=
'all') {
130 $handlers = array_merge($handlers, array_values($this->handlers[
$name][$type]));
133 if (isset($this->handlers[
'all'][$type])) {
134 if ($type !=
'all') {
135 $handlers = array_merge($handlers, array_values($this->handlers[
'all'][$type]));
138 if (isset($this->handlers[
$name][
'all'])) {
139 if ($name !=
'all') {
140 $handlers = array_merge($handlers, array_values($this->handlers[$name][
'all']));
143 if (isset($this->handlers[
'all'][
'all'])) {
144 $handlers = array_merge($handlers, array_values($this->handlers[
'all'][
'all']));
159 if (is_string($callable)) {
162 if (is_array($callable) && array_keys($callable) === array(0, 1) && is_string($callable[1])) {
163 if (is_string($callable[0])) {
164 return "{$callable[0]}::{$callable[1]}";
166 return "(" . get_class($callable[0]) .
")->{$callable[1]}";
168 if ($callable instanceof Closure) {
169 $ref =
new ReflectionFunction($callable);
170 $file = $ref->getFileName();
171 $line = $ref->getStartLine();
172 return "(Closure {$file}:{$line})";
174 if (is_object($callable)) {
175 return "(" . get_class($callable) .
")->__invoke()";
unregisterHandler($name, $type, $callback)
Unregister a handler.
describeCallable($callable)
Get a string description of a callback.
if($guid==elgg_get_logged_in_user_guid()) $name
registerHandler($name, $type, $callback, $priority=500)
Registers a handler.
setLogger(Elgg_Logger $logger=null)
Set a logger instance, e.g.
hasHandler($name, $type)
Does the hook have a handler?
getAllHandlers()
Returns all registered handlers as array( $name => array( $type => array( $priority => callback...
getOrderedHandlers($name, $type)
Returns an ordered array of handlers registered for $name and $type.