- 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:
parent
5e54407f74
commit
934643214e
|
@ -96,9 +96,9 @@ You can do so by using `define` and `slot`.
|
||||||
```html
|
```html
|
||||||
{% arguments string $name, string $anchor, int $index = 0 %}
|
{% arguments string $name, string $anchor, int $index = 0 %}
|
||||||
|
|
||||||
{% define slot %}
|
{% define "attributes" %}
|
||||||
|
|
||||||
<a {% slot "attributes" %}href="{{ $anchor }}" tabindex="{{ $index }}"{% endslot %}>{{ $name }}"</a>
|
<a {% slot "attributes" %}{% endslot %} href="{{ $anchor }}" tabindex="{{ $index }}"{% endslot %}>{{ $name }}"</a>
|
||||||
```
|
```
|
||||||
|
|
||||||
**[HTML]** Would render the same as the `view` example :
|
**[HTML]** Would render the same as the `view` example :
|
||||||
|
|
|
@ -184,7 +184,7 @@ class BlockToken implements ControlStructure {
|
||||||
public function printDefinition(string $name) : string
|
public function printDefinition(string $name) : string
|
||||||
{
|
{
|
||||||
if ( ! isset($this->definitions[$name]) ) {
|
if ( ! isset($this->definitions[$name]) ) {
|
||||||
throw new \Exception("Slot definition for `$name` was not found. Have you defined it in your block header ?");
|
throw new \Exception("Slot definition for `$name` was not found. Have you defined it in your block header using something like '{% define \"$name\", ...\$arguments %}' ?");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->definitions[$name];
|
return $this->definitions[$name];
|
||||||
|
@ -194,7 +194,6 @@ class BlockToken implements ControlStructure {
|
||||||
{
|
{
|
||||||
$this->rendering = true;
|
$this->rendering = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ PATTERN;
|
||||||
|
|
||||||
public function buildRouteUrl(string $name, array $parameters = [], bool $appendVersion = false) : string
|
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);
|
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
|
public function registerRoute(string $name, string $route, string $class, string $method, array $routeMethods) : void
|
||||||
{
|
{
|
||||||
$this->routes[$name] = [
|
$this->routes[] = $array = [
|
||||||
|
'name' => $name,
|
||||||
'route' => $route,
|
'route' => $route,
|
||||||
'routeMethods' => $routeMethods,
|
'routeMethods' => array_map('strtoupper', $routeMethods),
|
||||||
'class' => $class,
|
'class' => $class,
|
||||||
'classMethod' => $method,
|
'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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue