- Fixed a part of Block's doc ; more work to be done on that part
- Fixed whitespaces from unprinted block parts - Reworked a bit the UrlExtension route grabbing part
This commit is contained in:
1 parent
5e54407f74
commit
934643214e
3 files changed
+23
-12
No files matched your search
@@ -120,7 +120,7 @@ PATTERN;
|
||||
|
||||
public function buildRouteUrl(string $name, array $parameters = [], bool $appendVersion = false) : string
|
||||
{
|
||||
if ( false !== ( $route = $this->routes[$name] ?? false ) ) {
|
||||
if ( false !== $route = $this->findRoute($name) ) {
|
||||
return $this->buildUrl($this->prepareRoute($route, $parameters), $parameters, $appendVersion);
|
||||
}
|
||||
|
||||
@@ -149,14 +149,26 @@ PATTERN;
|
||||
|
||||
public function registerRoute(string $name, string $route, string $class, string $method, array $routeMethods) : void
|
||||
{
|
||||
$this->routes[$name] = [
|
||||
$this->routes[] = $array = [
|
||||
'name' => $name,
|
||||
'route' => $route,
|
||||
'routeMethods' => $routeMethods,
|
||||
'routeMethods' => array_map('strtoupper', $routeMethods),
|
||||
'class' => $class,
|
||||
'classMethod' => $method,
|
||||
];
|
||||
|
||||
$this->eventExecute(UrlRegisterRouteEvent::class, $name, $this->routes[$name]);
|
||||
$this->eventExecute(UrlRegisterRouteEvent::class, $name, $array);
|
||||
}
|
||||
|
||||
protected function findRoute(string $name, string $method = "GET") : false|array
|
||||
{
|
||||
foreach($this->routes as $route) {
|
||||
if ( ($route['name'] === $name) && in_array(strtoupper($method), $route['routeMethods']) ) {
|
||||
return $route;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user