8000 addFlag function to add flag for pattern by syrian-dev · Pull Request #200 · bramus/router · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

addFlag function to add flag for pattern #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Bramus/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
class Router
{

private $flag = '';
/**
* @var array The route patterns and their handling functions
*/
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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));
}

/**
Expand Down
0