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
01ddff5c
Commit
01ddff5c
authored
Feb 28, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding support for filter patterns.
Signed-off-by:
Taylor Otwell
<
taylorotwell@gmail.com
>
parent
99544821
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
filter.php
laravel/routing/filter.php
+18
-1
uri.php
laravel/uri.php
+5
-2
No files found.
laravel/routing/filter.php
View file @
01ddff5c
...
...
@@ -13,6 +13,13 @@ class Filter {
*/
public
static
$filters
=
array
();
/**
* The route filters that are based on pattern.
*
* @var array
*/
public
static
$patterns
=
array
();
/**
* All of the registered filter aliases.
*
...
...
@@ -39,8 +46,18 @@ class Filter {
{
if
(
isset
(
static
::
$aliases
[
$name
]))
$name
=
static
::
$aliases
[
$name
];
if
(
starts_with
(
$name
,
'pattern: '
))
{
foreach
(
explode
(
', '
,
substr
(
$name
,
9
))
as
$pattern
)
{
static
::
$patterns
[
$pattern
]
=
$callback
;
}
}
else
{
static
::
$filters
[
$name
]
=
$callback
;
}
}
/**
* Alias a filter so it can be used by another name.
...
...
laravel/uri.php
View file @
01ddff5c
...
...
@@ -116,10 +116,13 @@ class URI {
* Determine if the current URI matches a given pattern.
*
* @param string $pattern
* @param string $uri
* @return bool
*/
public
static
function
is
(
$pattern
)
public
static
function
is
(
$pattern
,
$uri
=
null
)
{
$uri
=
$uri
?:
static
::
current
();
// Asterisks are translated into zero-or-more regular expression wildcards
// to make it convenient to check if the URI starts with a given pattern
// such as "library/*". This is only done when not root.
...
...
@@ -132,7 +135,7 @@ class URI {
$pattern
=
'^/$'
;
}
return
preg_match
(
'#'
.
$pattern
.
'#'
,
static
::
current
()
);
return
preg_match
(
'#'
.
$pattern
.
'#'
,
$uri
);
}
/**
...
...
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