- Added a new Include token (which was added as RAW content)

- Fixed UrlExtension to reflect on notes-routes changes
- Added some methods to FileFetcher
This commit is contained in:
mcndave committed 2020-10-20 19:38:37 +00:00
1 parent 10632e9f67
commit 2f8abebc44
6 files changed
+41 -17

No files matched your search

+15 -3
View File
@@ -12,6 +12,8 @@ class UrlExtension implements Extension {
protected array $routes;
protected array $routesTarget;
public array $tokens = [ "url" , "route", "asset", "url.parameters" ];
public function __construct(Context $context, string $urlBase = "", string $assetToken = "") {
@@ -46,6 +48,11 @@ class UrlExtension implements Extension {
$context->pushFunction("route", [ $this, 'buildRouteUrl' ]);
}
public function getRouteList(bool $full = false) : array
{
return $this->routes;
}
public function setUrlParameters(string $url = "", array $parameters = []) : string
{
return $url . ( $parameters ? "?" . http_build_query($parameters) : "" );
@@ -64,7 +71,7 @@ class UrlExtension implements Extension {
public function buildRouteUrl(string $name, array $parameters = []) : string
{
if ( false !== ( $route = $this->routes[$name] ?? false ) ) {
return $this->buildUrl($this->prepareRoute($route, $parameters), $parameters);
return $this->buildUrl($this->prepareRoute($route['route'], $parameters), $parameters);
}
$routeList = json_encode($this->routes, \JSON_PRETTY_PRINT);
@@ -80,9 +87,14 @@ class UrlExtension implements Extension {
return $this->scheme() . $this->domain() . $this->base();
}
public function registerRoute(string $name, string $route) : void
public function registerRoute(string $name, string $route, string $class, string $method, array $routeMethods) : void
{
$this->routes[$name] = $route;
$this->routes[$name] = [
'route' => $route,
'routeMethods' => $routeMethods,
'class' => $class,
'classMethod' => $method,
];
}
/**