From 438193ef59467b5e3d8d07bf91f5d1433aeb52a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Mon, 29 Mar 2021 21:59:30 +0200 Subject: [PATCH] Added deprecated warning for RoutePartialGroup. --- README.md | 1 - src/Pecee/SimpleRouter/Route/RouteGroup.php | 14 +++++-- .../SimpleRouter/Route/RoutePartialGroup.php | 37 ++----------------- 3 files changed, 15 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 95abad6..d795375 100644 --- a/README.md +++ b/README.md @@ -688,7 +688,6 @@ SimpleRouter::partialGroup('/lang/{language}', function ($language) { }); ``` - ## Form Method Spoofing HTML forms do not support `PUT`, `PATCH` or `DELETE` actions. So, when defining `PUT`, `PATCH` or `DELETE` routes that are called from an HTML form, you will need to add a hidden `_method` field to the form. The value sent with the `_method` field will be used as the HTTP request method: diff --git a/src/Pecee/SimpleRouter/Route/RouteGroup.php b/src/Pecee/SimpleRouter/Route/RouteGroup.php index 6520cc8..d605091 100644 --- a/src/Pecee/SimpleRouter/Route/RouteGroup.php +++ b/src/Pecee/SimpleRouter/Route/RouteGroup.php @@ -56,9 +56,17 @@ class RouteGroup extends Route implements IGroupRoute return false; } - // Parse group prefix parameters - if(count($this->originalParameters) === 0) { - $this->parseParameters($this->prefix, $url); + if ($this->prefix !== null) { + /* Parse parameters from current route */ + $parameters = $this->parseParameters($this->prefix, $url); + + /* If no custom regular expression or parameters was found on this route, we stop */ + if ($parameters === null) { + return false; + } + + /* Set the parameters */ + $this->setParameters($parameters); } $parsedPrefix = $this->prefix; diff --git a/src/Pecee/SimpleRouter/Route/RoutePartialGroup.php b/src/Pecee/SimpleRouter/Route/RoutePartialGroup.php index 9960d29..901bd45 100644 --- a/src/Pecee/SimpleRouter/Route/RoutePartialGroup.php +++ b/src/Pecee/SimpleRouter/Route/RoutePartialGroup.php @@ -1,40 +1,11 @@ getGroup() !== null && $this->getGroup()->matchRoute($url, $request) === false) { - return false; - } - - if ($this->prefix !== null) { - /* Parse parameters from current route */ - $parameters = $this->parseParameters($this->prefix, $url); - - /* If no custom regular expression or parameters was found on this route, we stop */ - if ($parameters === null) { - return false; - } - - /* Set the parameters */ - $this->setParameters($parameters); - } - - return $this->matchDomain($request); - } } \ No newline at end of file