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
2fae372c
Commit
2fae372c
authored
Sep 14, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring routing classes.
parent
bae9553a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
18 deletions
+13
-18
caller.php
laravel/routing/caller.php
+5
-5
route.php
laravel/routing/route.php
+1
-1
router.php
laravel/routing/router.php
+7
-12
No files found.
laravel/routing/caller.php
View file @
2fae372c
...
@@ -62,8 +62,8 @@ class Caller {
...
@@ -62,8 +62,8 @@ class Caller {
{
{
// If a route returns a string, it also means the route is delegating the
// If a route returns a string, it also means the route is delegating the
// handling of the request to a controller method. So, we will pass the
// handling of the request to a controller method. So, we will pass the
// string to the route delegator, exploding on "
::
".
// string to the route delegator, exploding on "
@
".
if
(
is_string
(
$response
))
$response
=
$this
->
delegate
(
$route
,
explode
(
'::'
,
$response
)
);
if
(
is_string
(
$response
))
$response
=
$this
->
delegate
(
$route
,
$response
);
return
$this
->
finish
(
$route
,
$response
);
return
$this
->
finish
(
$route
,
$response
);
}
}
...
@@ -93,12 +93,12 @@ class Caller {
...
@@ -93,12 +93,12 @@ class Caller {
* Handle the delegation of a route to a controller method.
* Handle the delegation of a route to a controller method.
*
*
* @param Route $route
* @param Route $route
* @param
array
$delegate
* @param
string
$delegate
* @return mixed
* @return mixed
*/
*/
protected
function
delegate
(
Route
$route
,
$delegate
)
protected
function
delegate
(
Route
$route
,
$delegate
)
{
{
list
(
$controller
,
$method
)
=
array
(
$delegate
[
0
],
$delegate
[
1
]
);
list
(
$controller
,
$method
)
=
explode
(
'@'
,
$delegate
);
$controller
=
$this
->
resolve
(
$controller
);
$controller
=
$this
->
resolve
(
$controller
);
...
...
laravel/routing/route.php
View file @
2fae372c
...
@@ -67,7 +67,7 @@ class Route {
...
@@ -67,7 +67,7 @@ class Route {
}
}
/**
/**
* Call the
route closure
.
* Call the
closure defined for the route, or get the route delegator
.
*
*
* @return mixed
* @return mixed
*/
*/
...
...
laravel/routing/router.php
View file @
2fae372c
...
@@ -23,19 +23,19 @@ class Router {
...
@@ -23,19 +23,19 @@ class Router {
*
*
* @var string
* @var string
*/
*/
protected
$controller
_path
;
protected
$controller
s
;
/**
/**
* Create a new router for a request method and URI.
* Create a new router for a request method and URI.
*
*
* @param array $routes
* @param array $routes
* @param string $controller
_path
* @param string $controller
s
* @return void
* @return void
*/
*/
public
function
__construct
(
$routes
,
$controller
_path
)
public
function
__construct
(
$routes
,
$controller
s
)
{
{
$this
->
routes
=
$routes
;
$this
->
routes
=
$routes
;
$this
->
controller
_path
=
$controller_path
;
$this
->
controller
s
=
$controllers
;
}
}
/**
/**
...
@@ -121,7 +121,7 @@ class Router {
...
@@ -121,7 +121,7 @@ class Router {
{
{
// If the request is to the root of the application, an ad-hoc route will be generated
// If the request is to the root of the application, an ad-hoc route will be generated
// to the home controller's "index" method, making it the default controller method.
// to the home controller's "index" method, making it the default controller method.
if
(
$request
->
uri
()
===
'/'
)
return
new
Route
(
$request
->
method
()
.
' /'
,
function
()
{
return
array
(
'home'
,
'index'
);
}
);
if
(
$request
->
uri
()
===
'/'
)
return
new
Route
(
$request
->
method
()
.
' /'
,
'home@index'
);
$segments
=
explode
(
'/'
,
trim
(
$request
->
uri
(),
'/'
));
$segments
=
explode
(
'/'
,
trim
(
$request
->
uri
(),
'/'
));
...
@@ -142,12 +142,7 @@ class Router {
...
@@ -142,12 +142,7 @@ class Router {
// be used as the default controller method.
// be used as the default controller method.
$method
=
(
count
(
$segments
)
>
0
)
?
array_shift
(
$segments
)
:
'index'
;
$method
=
(
count
(
$segments
)
>
0
)
?
array_shift
(
$segments
)
:
'index'
;
// Now we're ready to dummy up a controller delegating route callback. This
return
new
Route
(
$destination
,
$controller
.
'@'
.
$method
,
$segments
);
// callback will look exactly like the callback the developer would create
// were they to code the controller delegation manually.
$callback
=
function
()
use
(
$controller
,
$method
)
{
return
array
(
$controller
,
$method
);
};
return
new
Route
(
$destination
,
$callback
,
$segments
);
}
}
}
}
...
@@ -167,7 +162,7 @@ class Router {
...
@@ -167,7 +162,7 @@ class Router {
{
{
foreach
(
array_reverse
(
$segments
,
true
)
as
$key
=>
$value
)
foreach
(
array_reverse
(
$segments
,
true
)
as
$key
=>
$value
)
{
{
if
(
file_exists
(
$path
=
$this
->
controller
_path
.
implode
(
'/'
,
array_slice
(
$segments
,
0
,
$key
+
1
))
.
EXT
))
if
(
file_exists
(
$path
=
$this
->
controller
s
.
implode
(
'/'
,
array_slice
(
$segments
,
0
,
$key
+
1
))
.
EXT
))
{
{
return
$key
+
1
;
return
$key
+
1
;
}
}
...
...
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