From c9f14748738761e6acf5e34d8a7d31550fb9b57c Mon Sep 17 00:00:00 2001 From: mrjk990 Date: Tue, 28 Feb 2023 03:31:56 +0200 Subject: [PATCH] addFlag function to add flag for patter for me arabic word didnot found and route ! this method w'll fix it $router = new \Bramus\Router\Router(); $router->addFlag('u'); $router->get('/search/movie/([\p{L}\d\-]+)', 'search@movieByTitle'); --- src/Bramus/Router/Router.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Bramus/Router/Router.php b/src/Bramus/Router/Router.php index d5c81f1..0eb8e9a 100644 --- a/src/Bramus/Router/Router.php +++ b/src/Bramus/Router/Router.php @@ -12,6 +12,8 @@ */ class Router { + + private $flag = ''; /** * @var array The route patterns and their handling functions */ @@ -46,6 +48,11 @@ class Router * @var string Default Controllers Namespace */ private $namespace = ''; + + + public function addFlag($flag){ + $this->flag = trim($flag); + } /** * Store a before middleware route and a handling function to be executed when accessed using one of the specified methods. @@ -66,6 +73,8 @@ public function before($methods, $pattern, $fn) ); } } + + /** * Store a route and a handling function to be executed when accessed using one of the specified methods. @@ -392,7 +401,7 @@ private function patternMatches($pattern, $uri, &$matches, $flags) $pattern = preg_replace('/\/{(.*?)}/', '/(.*?)', $pattern); // we may have a match! - return boolval(preg_match_all('#^' . $pattern . '$#', $uri, $matches, PREG_OFFSET_CAPTURE)); + return boolval(preg_match_all('#^' . $pattern . '$#'.$this->flag, $uri, $matches, PREG_OFFSET_CAPTURE)); } /**