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
a38ba2a6
Commit
a38ba2a6
authored
Nov 09, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up controller and session.
parent
a1e82d21
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
69 deletions
+18
-69
controller.php
laravel/routing/controller.php
+16
-67
route.php
laravel/routing/route.php
+1
-1
session.php
laravel/session.php
+1
-1
No files found.
laravel/routing/controller.php
View file @
a38ba2a6
...
@@ -35,7 +35,7 @@ abstract class Controller {
...
@@ -35,7 +35,7 @@ abstract class Controller {
* @param array $parameters
* @param array $parameters
* @return Response
* @return Response
*/
*/
public
static
function
_
call
(
$destination
,
$parameters
=
array
())
public
static
function
call
(
$destination
,
$parameters
=
array
())
{
{
if
(
strpos
(
$destination
,
'@'
)
===
false
)
if
(
strpos
(
$destination
,
'@'
)
===
false
)
{
{
...
@@ -44,14 +44,14 @@ abstract class Controller {
...
@@ -44,14 +44,14 @@ abstract class Controller {
list
(
$controller
,
$method
)
=
explode
(
'@'
,
$destination
);
list
(
$controller
,
$method
)
=
explode
(
'@'
,
$destination
);
$controller
=
static
::
_
resolve
(
$controller
);
$controller
=
static
::
resolve
(
$controller
);
if
(
is_null
(
$controller
))
if
(
is_null
(
$controller
))
{
{
return
Response
::
error
(
'404'
);
return
Response
::
error
(
'404'
);
}
}
return
$controller
->
_
execute
(
$method
,
$parameters
);
return
$controller
->
execute
(
$method
,
$parameters
);
}
}
/**
/**
...
@@ -61,9 +61,9 @@ abstract class Controller {
...
@@ -61,9 +61,9 @@ abstract class Controller {
* @param string $controller
* @param string $controller
* @return Controller
* @return Controller
*/
*/
public
static
function
_
resolve
(
$controller
)
public
static
function
resolve
(
$controller
)
{
{
if
(
!
static
::
_
load
(
$controller
))
return
;
if
(
!
static
::
load
(
$controller
))
return
;
// If the controller is registered in the IoC container, we will resolve
// If the controller is registered in the IoC container, we will resolve
// it out of the container. Using constructor injection on controllers
// it out of the container. Using constructor injection on controllers
...
@@ -94,7 +94,7 @@ abstract class Controller {
...
@@ -94,7 +94,7 @@ abstract class Controller {
* @param string $controller
* @param string $controller
* @return bool
* @return bool
*/
*/
protected
static
function
_
load
(
$controller
)
protected
static
function
load
(
$controller
)
{
{
$controller
=
strtolower
(
str_replace
(
'.'
,
'/'
,
$controller
));
$controller
=
strtolower
(
str_replace
(
'.'
,
'/'
,
$controller
));
...
@@ -115,18 +115,13 @@ abstract class Controller {
...
@@ -115,18 +115,13 @@ abstract class Controller {
* @param array $parameters
* @param array $parameters
* @return Response
* @return Response
*/
*/
public
function
_
execute
(
$method
,
$parameters
=
array
())
public
function
execute
(
$method
,
$parameters
=
array
())
{
{
if
(
static
::
_hidden
(
$method
))
{
return
Response
::
error
(
'404'
);
}
// Again, as was the case with route closures, if the controller
// Again, as was the case with route closures, if the controller
// "before" filters return a response, it will be considered the
// "before" filters return a response, it will be considered the
// response to the request and the controller method will not be
// response to the request and the controller method will not be
// used to handle the request to the application.
// used to handle the request to the application.
$response
=
Filter
::
run
(
$this
->
gather_
filters
(
'before'
,
$method
),
array
(),
true
);
$response
=
Filter
::
run
(
$this
->
filters
(
'before'
,
$method
),
array
(),
true
);
if
(
is_null
(
$response
))
if
(
is_null
(
$response
))
{
{
...
@@ -135,7 +130,7 @@ abstract class Controller {
...
@@ -135,7 +130,7 @@ abstract class Controller {
// If the controller has specified a layout view. The response
// If the controller has specified a layout view. The response
// returned by the controller method will be bound to that view
// returned by the controller method will be bound to that view
// and the layout will be considered the response.
// and the layout will be considered the response.
if
(
!
is_null
(
$this
->
layout
)
and
$this
->
_
viewable
(
$response
))
if
(
!
is_null
(
$this
->
layout
)
and
$this
->
viewable
(
$response
))
{
{
$response
=
$this
->
layout
->
with
(
'content'
,
$response
);
$response
=
$this
->
layout
->
with
(
'content'
,
$response
);
}
}
...
@@ -149,24 +144,11 @@ abstract class Controller {
...
@@ -149,24 +144,11 @@ abstract class Controller {
$response
=
new
Response
(
$response
);
$response
=
new
Response
(
$response
);
}
}
Filter
::
run
(
$this
->
gather_
filters
(
'after'
,
$method
),
array
(
$response
));
Filter
::
run
(
$this
->
filters
(
'after'
,
$method
),
array
(
$response
));
return
$response
;
return
$response
;
}
}
/**
* Determine if a given controller method is callable.
*
* @param string $method
* @return bool
*/
protected
static
function
_hidden
(
$method
)
{
$hidden
=
array
(
'before'
,
'after'
,
'register_filters'
,
'gather_filters'
);
return
strncmp
(
$method
,
'_'
,
1
)
==
0
or
in_array
(
$method
,
$hidden
);
}
/**
/**
* Deteremine if a given response is considered "viewable".
* Deteremine if a given response is considered "viewable".
*
*
...
@@ -178,7 +160,7 @@ abstract class Controller {
...
@@ -178,7 +160,7 @@ abstract class Controller {
* @param mixed $response
* @param mixed $response
* @return bool
* @return bool
*/
*/
protected
function
_
viewable
(
$response
)
protected
function
viewable
(
$response
)
{
{
if
(
$response
instanceof
Response
)
if
(
$response
instanceof
Response
)
{
{
...
@@ -196,55 +178,22 @@ abstract class Controller {
...
@@ -196,55 +178,22 @@ abstract class Controller {
}
}
/**
/**
* Register "before" filters on the controller's methods.
* Register filters on the controller's methods.
*
* Generally, this method will be used in the controller's constructor.
*
* <code>
* // Set a "foo" before filter on the controller
* $this->before_filter('foo');
*
* // Set several filters on an explicit group of methods
* $this->before_filter('foo|bar')->only(array('user', 'profile'));
* </code>
*
* @param string|array $filters
* @return Filter_Collection
*/
public
function
before
(
$filters
)
{
return
$this
->
register_filters
(
'before'
,
$filters
);
}
/**
* Register "after" filters on the controller's methods.
*
*
* Generally, this method will be used in the controller's constructor.
* Generally, this method will be used in the controller's constructor.
*
*
* <code>
* <code>
* // Set a "foo" after filter on the controller
* // Set a "foo" after filter on the controller
* $this->
after_filter(
'foo');
* $this->
filter('before',
'foo');
*
*
* // Set several filters on an explicit group of methods
* // Set several filters on an explicit group of methods
* $this->
after_filter(
'foo|bar')->only(array('user', 'profile'));
* $this->
filter('after',
'foo|bar')->only(array('user', 'profile'));
* </code>
* </code>
*
*
* @param string|array $filters
* @param string|array $filters
* @return Filter_Collection
* @return Filter_Collection
*/
*/
public
function
after
(
$filters
)
protected
function
filter
(
$name
,
$filters
)
{
return
$this
->
register_filters
(
'after'
,
$filters
);
}
/**
* Set filters on the controller's methods.
*
* @param string $name
* @param string|array $filters
* @return Filter_Collection
*/
protected
function
register_filters
(
$name
,
$filters
)
{
{
$this
->
filters
[]
=
new
Filter_Collection
(
$name
,
$filters
);
$this
->
filters
[]
=
new
Filter_Collection
(
$name
,
$filters
);
...
@@ -258,7 +207,7 @@ abstract class Controller {
...
@@ -258,7 +207,7 @@ abstract class Controller {
* @param string $method
* @param string $method
* @return array
* @return array
*/
*/
protected
function
gather_
filters
(
$name
,
$method
)
protected
function
filters
(
$name
,
$method
)
{
{
$filters
=
array
();
$filters
=
array
();
...
...
laravel/routing/route.php
View file @
a38ba2a6
...
@@ -107,7 +107,7 @@ class Route {
...
@@ -107,7 +107,7 @@ class Route {
{
{
if
(
$response
instanceof
Delegate
)
if
(
$response
instanceof
Delegate
)
{
{
$response
=
Controller
::
_
call
(
$response
->
destination
,
$this
->
parameters
);
$response
=
Controller
::
call
(
$response
->
destination
,
$this
->
parameters
);
}
}
}
}
...
...
laravel/session.php
View file @
a38ba2a6
...
@@ -16,7 +16,7 @@ class Session {
...
@@ -16,7 +16,7 @@ class Session {
*
*
* @var array
* @var array
*/
*/
p
rotected
$session
;
p
ublic
$session
;
/**
/**
* Indicates if the session already exists in storage.
* Indicates if the session already exists in storage.
...
...
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