Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
d0ba4719
Commit
d0ba4719
authored
Jul 10, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extracted the route wildcard translation to a separate method.
parent
82776946
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
router.php
system/router.php
+12
-3
No files found.
system/router.php
View file @
d0ba4719
...
...
@@ -41,9 +41,7 @@ class Router {
{
foreach
(
explode
(
', '
,
$keys
)
as
$key
)
{
$key
=
str_replace
(
':num'
,
'[0-9]+'
,
str_replace
(
':any'
,
'[a-zA-Z0-9\-_]+'
,
$key
));
if
(
preg_match
(
'#^'
.
$key
.
'$#'
,
$uri
))
if
(
preg_match
(
'#^'
.
$key
=
static
::
translate_wildcards
(
$key
)
.
'$#'
,
$uri
))
{
return
Request
::
$route
=
new
Route
(
$keys
,
$callback
,
static
::
parameters
(
$uri
,
$key
));
}
...
...
@@ -85,6 +83,17 @@ class Router {
return
(
file_exists
(
$path
=
APP_PATH
.
'routes/'
.
$segments
[
0
]
.
EXT
))
?
array_merge
(
require
$path
,
$home
)
:
$home
;
}
/**
* Translate route URI wildcards to regular expressions.
*
* @param string $key
* @return string
*/
private
static
function
translate_wildcards
(
$key
)
{
return
str_replace
(
':num'
,
'[0-9]+'
,
str_replace
(
':any'
,
'[a-zA-Z0-9\-_]+'
,
$key
));
}
/**
* Extract the parameters from a URI based on a route URI.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment