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
80c746ed
Commit
80c746ed
authored
Jul 07, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor route parameter parsing.
parent
b5e0eb02
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
20 deletions
+4
-20
router.php
system/router.php
+4
-20
No files found.
system/router.php
View file @
80c746ed
...
...
@@ -44,13 +44,7 @@ class Router {
if
(
preg_match
(
'#^'
.
$key
.
'$#'
,
$method
.
' '
.
$uri
))
{
// Remove the leading slashes from the route and request URIs. Also trim
// the request method off of the route URI. This should get the request
// and route URIs in the same format so we can extract the parameters.
$uri
=
trim
(
$uri
,
'/'
);
$key
=
trim
(
substr
(
$key
,
strlen
(
$method
.
' '
)),
'/'
);
return
Request
::
$route
=
new
Route
(
$keys
,
$callback
,
static
::
parameters
(
explode
(
'/'
,
$uri
),
explode
(
'/'
,
$key
)));
return
Request
::
$route
=
new
Route
(
$keys
,
$callback
,
static
::
parameters
(
$uri
,
$key
));
}
}
}
...
...
@@ -92,23 +86,13 @@ class Router {
*
* Any route segment wrapped in parentheses is considered a parameter.
*
* @param
array
$uri
* @param
array
$route
* @param
string
$uri
* @param
string
$route
* @return array
*/
private
static
function
parameters
(
$uri
,
$route
)
{
$parameters
=
array
();
for
(
$i
=
0
;
$i
<
count
(
$route
);
$i
++
)
{
if
(
strpos
(
$route
[
$i
],
'('
)
===
0
)
{
$parameters
[]
=
$uri
[
$i
];
}
}
return
$parameters
;
return
array_values
(
array_intersect_key
(
explode
(
'/'
,
$uri
),
preg_grep
(
'/\(.+\)/'
,
explode
(
'/'
,
$route
))));
}
}
\ No newline at end of file
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