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
7aecd785
Commit
7aecd785
authored
Jan 27, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring the router.
parent
54e0bef6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
helpers.php
laravel/helpers.php
+11
-0
router.php
laravel/routing/router.php
+11
-4
No files found.
laravel/helpers.php
View file @
7aecd785
...
...
@@ -219,6 +219,17 @@ function array_strip_slashes($array)
return
$result
;
}
/**
* Divide an array into two arrays. One with keys and the other with values.
*
* @param array $array
* @return array
*/
function
array_divide
(
$array
)
{
return
array
(
array_keys
(
$array
),
array_values
(
$array
));
}
/**
* Determine if "Magic Quotes" are enabled on the server.
*
...
...
laravel/routing/router.php
View file @
7aecd785
...
...
@@ -167,7 +167,9 @@ class Router {
$uri
=
ltrim
(
$uri
,
'/'
);
}
return
static
::
controller
(
$bundle
,
$method
,
$destination
,
Str
::
segments
(
$uri
));
$segments
=
Str
::
segments
(
$uri
);
return
static
::
controller
(
$bundle
,
$method
,
$destination
,
$segments
);
}
/**
...
...
@@ -285,21 +287,26 @@ class Router {
}
/**
* Translate route URI wildcards into
actual
regular expressions.
* Translate route URI wildcards into regular expressions.
*
* @param string $key
* @return string
*/
protected
static
function
wildcards
(
$key
)
{
list
(
$search
,
$replace
)
=
array_divide
(
static
::
$optional
);
// For optional parameters, first translate the wildcards to their
// regex equivalent, sans the ")?" ending. We'll add the endings
// back on after we know how many replacements we made.
$key
=
str_replace
(
array_keys
(
static
::
$optional
),
array_values
(
static
::
$optional
)
,
$key
,
$count
);
$key
=
str_replace
(
$search
,
$replace
,
$key
,
$count
);
$key
.=
(
$count
>
0
)
?
str_repeat
(
')?'
,
$count
)
:
''
;
return
str_replace
(
array_keys
(
static
::
$patterns
),
array_values
(
static
::
$patterns
),
$key
);
// For "regular" parameters, we can just do a simple translate
// using the patterns array. There is not need to cap the
// pattern like we did with optional parameters.
return
strtr
(
$key
,
static
::
$patterns
);
}
}
\ 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