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
86e109b7
Commit
86e109b7
authored
Feb 13, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify route parameter parsing and fix default value bug.
parent
2713ee9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
22 deletions
+2
-22
route.php
laravel/routing/route.php
+2
-22
No files found.
laravel/routing/route.php
View file @
86e109b7
...
...
@@ -78,38 +78,18 @@ class Route {
*/
protected
function
parameters
(
$uri
,
$action
,
$parameters
)
{
$wildcards
=
0
;
$defaults
=
(
array
)
array_get
(
$action
,
'defaults'
);
// We need to determine how many of the default paramters should be merged
// into the parameter array. First, we will count the number of wildcards
// in the route URI and then merge the defaults.
foreach
(
array_keys
(
Router
::
patterns
())
as
$wildcard
)
{
$wildcards
+=
substr_count
(
$uri
,
$wildcard
);
}
$needed
=
$wildcards
-
count
(
$parameters
);
// If there are less parameters than wildcards, we will figure out how
// many parameters we need to inject from the array of defaults and
// merge them in into the main array for the route.
if
(
$needed
>
0
)
if
(
count
(
$defaults
)
>
count
(
$parameters
)
)
{
$defaults
=
array_slice
(
$defaults
,
count
(
$
defaults
)
-
$needed
);
$defaults
=
array_slice
(
$defaults
,
count
(
$
parameters
)
);
$parameters
=
array_merge
(
$parameters
,
$defaults
);
}
// If the final number of parameters doesn't match the count of the
// wildcards, we'll pad parameter array with null to cover any of
// the default values that were forgotten.
if
(
count
(
$parameters
)
!==
$wildcards
)
{
$parameters
=
array_pad
(
$parameters
,
$wildcards
,
null
);
}
$this
->
parameters
=
$parameters
;
}
...
...
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