76 $params = $this->events->triggerResults(
'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);
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 ($walled !==
false) {
138 $middleware[] = WalledGarden::class;
141 $middleware[] = MaintenanceGatekeeper::class;
149 $defaults[
'_required_plugins'] = $required_plugins;
150 $defaults[
'_detect_page_owner'] = $detect_page_owner;
156 $this->routes->add($name, $route,
$priority);
169 $this->routes->remove($name);
180 return $this->routes->get($name);
187 public function all(): array {
188 return $this->routes->all();
199 public function generateUrl(
string $name, array $parameters = []): ?string {
201 $route = $this->
get(
$name);
202 if ($route instanceof
Route) {
203 $deprecated = $route->getDefault(
'_deprecated');
204 if (!empty($deprecated)) {
209 $url = $this->generator->generate($name, $parameters, UrlGenerator::ABSOLUTE_URL);
214 $this->
getLogger()->notice($exception->getMessage());
230 $route = $this->routes->get($name);
235 $requirements = $route->getRequirements();
237 $props = array_merge(array_keys($requirements), array_keys(
$defaults));
239 foreach ($props as $prop) {
240 if (str_starts_with($prop,
'_')) {
244 if (isset($parameters[$prop])) {
249 $parameters[$prop] =
'';
260 $parameters[$prop] =
$entity->$prop;
Exception thrown if an argument is not of the expected type.
$params
Saves global plugin settings.
__construct(EventsService $events, RouteCollection $routes, UrlGenerator $generator)
Constructor.
elgg_deprecated_notice(string $msg, string $dep_version)
Log a notice about deprecated use of a function, view, etc.
if(!$user||!$user->canDelete()) $name
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
generateUrl(string $name, array $parameters=[])
Generate a absolute URL for a named route.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
trait Loggable
Enables adding a logger.
unregister(string $name)
Unregister a route by its name.
elgg_get_friendly_title(string $title)
When given a title, returns a version suitable for inclusion in a URL.
getLogger()
Returns logger.
resolveRouteParameters(string $name,\ElggEntity $entity=null, array $parameters=[])
Populates route parameters from entity properties.
foreach($plugin_guids as $guid) if(empty($deactivated_plugins)) $url
all()
Get all registered routes.
Route registration service.
elgg_normalize_url(string $url)