From 53e6d5fde32a917718a0658fb95f366dc7dfc248 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sun, 26 Apr 2020 15:41:48 +0200 Subject: user bookmarks use new object + shortcuts visible in backtopbar --- app/class/Controller.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'app/class/Controller.php') diff --git a/app/class/Controller.php b/app/class/Controller.php index 34b3d11..46c9ee0 100644 --- a/app/class/Controller.php +++ b/app/class/Controller.php @@ -46,8 +46,8 @@ class Controller { $router = $this->router; $this->plates = new Engine(Model::TEMPLATES_DIR); - $this->plates->registerFunction('url', function (string $string, array $vars = []) { - return $this->generate($string, $vars); + $this->plates->registerFunction('url', function (string $string, array $vars = [], string $get = '') { + return $this->generate($string, $vars, $get); }); $this->plates->registerFunction('upage', function (string $string, string $id) { return $this->generate($string, ['page' => $id]); @@ -79,13 +79,14 @@ class Controller * * @param string $route The name of the route. * @param array $params Associative array of parameters to replace placeholders with. + * @param string $get Optionnal query GET parameters formated * @return string The URL of the route with named parameters in place. * @throws InvalidArgumentException If the route does not exist. */ - public function generate(string $route, array $params = []): string + public function generate(string $route, array $params = [], string $get = ''): string { try { - return $this->router->generate($route, $params); + return $this->router->generate($route, $params) . $get; } catch (Exception $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); } -- cgit v1.2.3