aboutsummaryrefslogtreecommitdiff
path: root/app/class/Controller.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/class/Controller.php')
-rw-r--r--app/class/Controller.php9
1 files changed, 5 insertions, 4 deletions
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);
}