Elgg  Version 2.3
PluginHooksService.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg;
4 
17 
24  public function trigger($hook, $type, $params = null, $returnvalue = null) {
25  $hooks = $this->getOrderedHandlers($hook, $type);
26 
27  foreach ($hooks as $callback) {
28  if (!is_callable($callback)) {
29  if ($this->logger) {
30  $inspector = new Inspector();
31  $this->logger->warn("handler for plugin hook [$hook, $type] is not callable: "
32  . $inspector->describeCallable($callback));
33  }
34  continue;
35  }
36 
37  $exit_warning = function() use ($hook, $type, $callback) {
38  $inspector = new Inspector();
40  "'$hook', '$type' plugin hook should not be used to serve a response. Instead return an "
41  . "appropriate ResponseBuilder instance from an action or page handler. Do not terminate "
42  . "code execution with exit() or die() in {$inspector->describeCallable($callback)}",
43  '2.3'
44  );
45  };
46 
47  if (in_array($hook, ['forward', 'action', 'route'])) {
48  _elgg_services()->events->registerHandler('shutdown', 'system', $exit_warning);
49  }
50 
51  $args = array($hook, $type, $returnvalue, $params);
52  $temp_return_value = call_user_func_array($callback, $args);
53  if (!is_null($temp_return_value)) {
54  $returnvalue = $temp_return_value;
55  }
56 
57  if (in_array($hook, ['forward', 'action', 'route'])) {
58  _elgg_services()->events->unregisterHandler('shutdown', 'system', $exit_warning);
59  }
60  }
61 
62  return $returnvalue;
63  }
64 
68  public function registerHandler($name, $type, $callback, $priority = 500) {
69  if (($name == 'view' || $name == 'view_vars') && $type !== 'all') {
70  $type = _elgg_services()->views->canonicalizeViewName($type);
71  }
72 
73  return parent::registerHandler($name, $type, $callback, $priority);
74  }
75 }
registerHandler($name, $type, $callback, $priority=500)
{}
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
$args
Some servers don&#39;t allow PHP to check the rewrite, so try via AJAX.
$params
Definition: login.php:72
Save menu items.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1098
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
trigger($hook, $type, $params=null, $returnvalue=null)
Triggers a plugin hook.
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:5
$priority
if(!$display_name) $type
Definition: delete.php:27