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
32684fa1
Commit
32684fa1
authored
Nov 12, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed router ioc bug.
parent
0e8432e3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
laravel.php
laravel/laravel.php
+2
-0
filter.php
laravel/routing/filter.php
+38
-0
No files found.
laravel/laravel.php
View file @
32684fa1
...
@@ -177,6 +177,8 @@ $loader = new Routing\Loader(APP_PATH, ROUTE_PATH);
...
@@ -177,6 +177,8 @@ $loader = new Routing\Loader(APP_PATH, ROUTE_PATH);
$router
=
new
Routing\Router
(
$loader
,
CONTROLLER_PATH
);
$router
=
new
Routing\Router
(
$loader
,
CONTROLLER_PATH
);
IoC
::
instance
(
'laravel.routing.router'
,
$router
);
Request
::
$route
=
$router
->
route
(
$method
,
$uri
);
Request
::
$route
=
$router
->
route
(
$method
,
$uri
);
if
(
!
is_null
(
Request
::
$route
))
if
(
!
is_null
(
Request
::
$route
))
...
...
laravel/routing/filter.php
View file @
32684fa1
<?php
namespace
Laravel\Routing
;
<?php
namespace
Laravel\Routing
;
use
Laravel\Request
;
class
Filter
{
class
Filter
{
/**
/**
...
@@ -98,6 +100,13 @@ class Filter_Collection {
...
@@ -98,6 +100,13 @@ class Filter_Collection {
*/
*/
public
$filters
=
array
();
public
$filters
=
array
();
/**
* The HTTP methods for which the filter applies.
*
* @var array
*/
public
$methods
=
array
();
/**
/**
* Create a new filter collection instance.
* Create a new filter collection instance.
*
*
...
@@ -128,6 +137,11 @@ class Filter_Collection {
...
@@ -128,6 +137,11 @@ class Filter_Collection {
return
false
;
return
false
;
}
}
if
(
count
(
$this
->
methods
)
>
0
and
!
in_array
(
strtolower
(
Request
::
method
()),
$this
->
methods
))
{
return
false
;
}
return
true
;
return
true
;
}
}
...
@@ -178,4 +192,28 @@ class Filter_Collection {
...
@@ -178,4 +192,28 @@ class Filter_Collection {
return
$this
;
return
$this
;
}
}
/**
* Set the HTTP methods for which the filter applies.
*
* Since some filters, such as the CSRF filter, only make sense in a POST
* request context, this method allows you to limit which HTTP methods
* the filter will apply to.
*
* <code>
* // Specify that a filter only applies on POST requests
* $this->filter('before', 'csrf')->on('post');
*
* // Specify that a filter applies for multiple HTTP request methods
* $this->filter('before', 'csrf')->on(array('post', 'put'));
* </code>
*
* @param array $methods
* @return Filter_Collection
*/
public
function
on
(
$methods
)
{
$this
->
methods
=
array_map
(
'strtolower'
,
(
array
)
$methods
);
return
$this
;
}
}
}
\ 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