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
d3d3ffc1
Commit
d3d3ffc1
authored
Jan 26, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring.
parent
a36e2773
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
31 deletions
+16
-31
router.php
laravel/routing/router.php
+13
-30
str.php
laravel/str.php
+3
-1
No files found.
laravel/routing/router.php
View file @
d3d3ffc1
...
@@ -76,7 +76,7 @@ class Router {
...
@@ -76,7 +76,7 @@ class Router {
{
{
// PHP 5.3.2 has a bug that causes closures cast as arrays
// PHP 5.3.2 has a bug that causes closures cast as arrays
// to yield an empty array. We will work around this by
// to yield an empty array. We will work around this by
// manually adding the Closure instance to a
new
array.
// manually adding the Closure instance to a
n
array.
if
(
$action
instanceof
Closure
)
$action
=
array
(
$action
);
if
(
$action
instanceof
Closure
)
$action
=
array
(
$action
);
static
::
$routes
[
$uri
]
=
(
array
)
$action
;
static
::
$routes
[
$uri
]
=
(
array
)
$action
;
...
@@ -87,8 +87,7 @@ class Router {
...
@@ -87,8 +87,7 @@ class Router {
}
}
/**
/**
* Find a route by name.
* Find a route by the route's assigned name.
*
*
*
* @param string $name
* @param string $name
* @return array
* @return array
...
@@ -142,42 +141,26 @@ class Router {
...
@@ -142,42 +141,26 @@ class Router {
// If we can't find a literal match, we'll iterate through all of
// If we can't find a literal match, we'll iterate through all of
// the registered routes attempting to find a matching route that
// the registered routes attempting to find a matching route that
// uses wildcards or regular expressions.
// uses wildcards or regular expressions.
if
(
!
is_null
(
$route
=
static
::
search
(
$destination
)))
{
return
$route
;
}
// If there are no literal matches and no routes that match the
// request, we'll use convention to search for a controller to
// handle the request. If no controller can be found, the 404
// error response will be returned by the application.
$segments
=
array_diff
(
explode
(
'/'
,
trim
(
$uri
,
'/'
)),
array
(
''
));
return
static
::
controller
(
DEFAULT_BUNDLE
,
$method
,
$destination
,
$segments
);
}
/**
* Attempt to match a destination to one of the registered routes.
*
* @param string $destination
* @return Route
*/
protected
static
function
search
(
$destination
)
{
foreach
(
static
::
$routes
as
$route
=>
$action
)
foreach
(
static
::
$routes
as
$route
=>
$action
)
{
{
// Since routes that don't use wildcards or regular expressions
// should have been caught by the literal route check, we will
// only check routes that have a parentheses, indicating that
// there are wildcards or regular expressions.
if
(
strpos
(
$route
,
'('
)
!==
false
)
if
(
strpos
(
$route
,
'('
)
!==
false
)
{
{
if
(
preg_match
(
'#^'
.
static
::
wildcards
(
$route
)
.
'$#'
,
$destination
,
$parameters
))
$pattern
=
'#^'
.
static
::
wildcards
(
$route
)
.
'$#'
;
if
(
preg_match
(
$pattern
,
$destination
,
$parameters
))
{
{
return
new
Route
(
$route
,
$action
,
array_slice
(
$parameters
,
1
));
return
new
Route
(
$route
,
$action
,
array_slice
(
$parameters
,
1
));
}
}
}
}
}
}
// If there are no literal matches and no routes that match the
// request, we'll use convention to search for a controller to
// handle the request. If no controller can be found, the 404
// error response will be returned.
$segments
=
array_diff
(
explode
(
'/'
,
trim
(
$uri
,
'/'
)),
array
(
''
));
return
static
::
controller
(
DEFAULT_BUNDLE
,
$method
,
$destination
,
$segments
);
}
}
/**
/**
...
...
laravel/str.php
View file @
d3d3ffc1
...
@@ -250,7 +250,9 @@ class Str {
...
@@ -250,7 +250,9 @@ class Str {
*/
*/
public
static
function
classify
(
$value
)
public
static
function
classify
(
$value
)
{
{
return
str_replace
(
' '
,
'_'
,
static
::
title
(
str_replace
(
array
(
'_'
,
'.'
),
' '
,
$value
)));
$search
=
array
(
'_'
,
'-'
,
'.'
);
return
str_replace
(
' '
,
'_'
,
static
::
title
(
str_replace
(
$search
,
' '
,
$value
)));
}
}
/**
/**
...
...
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