25 private $handlers = array();
34 $this->hooks = $hooks;
50 $identifier = array_shift($segments);
60 elgg_deprecated_notice(
"The 'index', 'system' plugin has been deprecated. See elgg_front_page_handler()", 1.9);
68 'identifier' => $identifier,
69 'handler' => $identifier,
70 'segments' => $segments,
74 $this->timer->begin([
'build page']);
79 $result = $this->hooks->trigger(
'route', $identifier, $old, $old);
85 _elgg_services()->logger->warn(
'Use the route:rewrite hook to modify routes.');
88 if ($identifier !=
$result[
'identifier']) {
89 $identifier =
$result[
'identifier'];
90 }
else if ($identifier !=
$result[
'handler']) {
91 $identifier =
$result[
'handler'];
94 $segments =
$result[
'segments'];
98 if (isset($this->handlers[$identifier]) && is_callable($this->handlers[$identifier])) {
99 $function = $this->handlers[$identifier];
100 $response = call_user_func($function, $segments, $identifier);
105 if ($response ===
false) {
106 return headers_sent();
119 return headers_sent();
132 if (is_callable($function,
true)) {
133 $this->handlers[$identifier] = $function;
148 unset($this->handlers[$identifier]);
157 return $this->handlers;
171 $identifier = array_shift($segments);
177 'identifier' => $identifier,
178 'segments' => $segments,
185 if (!isset(
$new[
'identifier']) || !isset(
$new[
'segments']) || !is_string(
$new[
'identifier']) || !is_array(
$new[
'segments'])
187 throw new RuntimeException(
'rewrite_path handler returned invalid route data.');
191 $segments =
$new[
'segments'];
192 array_unshift($segments,
$new[
'identifier']);
unregisterPageHandler($identifier)
Unregister a page handler for an identifier.
HTTP response builder interface.
getUrlSegments($raw=false)
Get the Elgg URL segments.
setUrlSegments(array $segments)
Get a cloned request with new Elgg URL segments.
trait Profilable
Make an object accept a timer.
registerPageHandler($identifier, $function)
Register a function that gets called when the first part of a URL is equal to the identifier...
__construct(PluginHooksService $hooks)
Constructor.
route(Request $request)
Routes the request to a registered page handler.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
getPageHandlers()
Get page handlers as array of identifier => callback.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
elgg_ok_response($content= '', $message= '', $forward_url=null, $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
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
allowRewrite(Request $request)
Filter a request through the route:rewrite hook.