76 $params = $this->hooks->trigger(
'route:config',
$name, $params, $params);
86 $required_plugins =
elgg_extract(
'required_plugins', $params, []);
87 $detect_page_owner = (bool)
elgg_extract(
'detect_page_owner', $params,
false);
88 $legacy_page_owner_detection = (bool)
elgg_extract(
'legacy_page_owner_detection', $params,
true);
92 __METHOD__ .
' requires "path" and one of controller parameters ("resource", "controller", "file" or "handler") to be set' 97 $requirements =
elgg_extract(
'requirements', $params, []);
102 'group_guid' =>
'\d+',
103 'container_guid' =>
'\d+',
104 'owner_guid' =>
'\d+',
105 'username' =>
'[\p{L}\p{M}\p{Nd}._-]+',
115 if (!
preg_match(
'/\{(\w*)(\?)?\}/i', $segment, $matches)) {
119 $wildcard = $matches[1];
120 if (!isset(
$defaults[$wildcard]) && isset($matches[2])) {
124 if (!isset($requirements[$wildcard])) {
125 if (array_key_exists($wildcard, $patterns)) {
126 $requirements[$wildcard] = $patterns[$wildcard];
128 $requirements[$wildcard] =
'.+?';
132 $segment =
'{' . $wildcard .
'}';
137 if ($protected !==
false) {
138 $middleware[] = WalledGarden::class;
141 $middleware[] = MaintenanceGatekeeper::class;
149 $defaults[
'_required_plugins'] = $required_plugins;
150 $defaults[
'_detect_page_owner'] = $detect_page_owner;
151 $defaults[
'_legacy_page_owner_detection'] = $legacy_page_owner_detection;
157 $this->routes->add(
$name, $route);
170 $this->routes->remove(
$name);
181 return $this->routes->get(
$name);
189 return $this->routes->all();
202 $route = $this->
get(
$name);
203 if ($route instanceof
Route) {
204 $deprecated = $route->getDefault(
'_deprecated');
205 if (!empty($deprecated)) {
210 $url = $this->generator->generate(
$name, $parameters, UrlGenerator::ABSOLUTE_URL);
215 $this->
getLogger()->notice($exception->getMessage());
231 $route = $this->routes->get(
$name);
236 $requirements = $route->getRequirements();
238 $props = array_merge(array_keys($requirements), array_keys(
$defaults));
240 foreach ($props as $prop) {
241 if (
substr($prop, 0, 1) ===
'_') {
245 if (isset($parameters[$prop])) {
250 $parameters[$prop] =
'';
261 $parameters[$prop] =
$entity->$prop;
unregister($name)
Unregister a route by its name.
$params
Saves global plugin settings.
elgg_deprecated_notice(string $msg, string $dep_version)
Log a notice about deprecated use of a function, view, etc.
if(!$user||!$user->canDelete()) $name
resolveRouteParameters($name,\ElggEntity $entity=null, array $parameters=[])
Populates route parameters from entity properties.
trait Loggable
Enables adding a logger.
if(elgg_view_exists('elgg/admin.js')) $segments
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
getLogger()
Returns logger.
foreach($plugin_guids as $guid) if(empty($deactivated_plugins)) $url
all()
Get all registered routes.
Route registration service.
elgg_get_friendly_title($title)
When given a title, returns a version suitable for inclusion in a URL.
__construct(PluginHooksService $hooks, RouteCollection $routes, UrlGenerator $generator)
Constructor.
generateUrl($name, array $parameters=[])
Generate a absolute URL for a named route.