Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
f27c0af9
Commit
f27c0af9
authored
Jan 12, 2018
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed before handlers not executed under mounts
parent
f33d8c9d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
doc/changelog.rst
doc/changelog.rst
+2
-2
src/Silex/ControllerCollection.php
src/Silex/ControllerCollection.php
+1
-0
tests/Silex/Tests/ControllerCollectionTest.php
tests/Silex/Tests/ControllerCollectionTest.php
+17
-0
No files found.
doc/changelog.rst
View file @
f27c0af9
Changelog
=========
2.2.2 (201
7-XX-XX
)
2.2.2 (201
8-01-12
)
------------------
*
n/a
*
[SECURITY] fixed before handlers not executed under mounts
2.2.1 (2017-12-14)
------------------
...
...
src/Silex/ControllerCollection.php
View file @
f27c0af9
...
...
@@ -68,6 +68,7 @@ class ControllerCollection
{
if
(
is_callable
(
$controllers
))
{
$collection
=
$this
->
controllersFactory
?
call_user_func
(
$this
->
controllersFactory
)
:
new
static
(
new
Route
(),
new
RouteCollection
());
$collection
->
defaultRoute
=
clone
$this
->
defaultRoute
;
call_user_func
(
$controllers
,
$collection
);
$controllers
=
$collection
;
}
elseif
(
!
$controllers
instanceof
self
)
{
...
...
tests/Silex/Tests/ControllerCollectionTest.php
View file @
f27c0af9
...
...
@@ -191,6 +191,23 @@ class ControllerCollectionTest extends TestCase
$this
->
assertEquals
(
'\w+'
,
$controller
->
getRoute
()
->
getRequirement
(
'extra'
));
}
public
function
testAssertWithMountCallable
()
{
$controllers
=
new
ControllerCollection
(
new
Route
());
$controller
=
null
;
$controllers
->
mount
(
'/{name}'
,
function
(
$mounted
)
use
(
&
$controller
)
{
$mounted
->
assert
(
'name'
,
'\w+'
);
$mounted
->
mount
(
'/{id}'
,
function
(
$mounted2
)
use
(
&
$controller
)
{
$mounted2
->
assert
(
'id'
,
'\d+'
);
$controller
=
$mounted2
->
match
(
'/{extra}'
,
function
()
{})
->
assert
(
'extra'
,
'\w+'
);
});
});
$this
->
assertEquals
(
'\d+'
,
$controller
->
getRoute
()
->
getRequirement
(
'id'
));
$this
->
assertEquals
(
'\w+'
,
$controller
->
getRoute
()
->
getRequirement
(
'name'
));
$this
->
assertEquals
(
'\w+'
,
$controller
->
getRoute
()
->
getRequirement
(
'extra'
));
}
public
function
testValue
()
{
$controllers
=
new
ControllerCollection
(
new
Route
());
...
...
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