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
48727b4d
Commit
48727b4d
authored
Jun 13, 2015
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cascade route configuration for embedded route collection
parent
cfb6ed09
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
src/Silex/ControllerCollection.php
src/Silex/ControllerCollection.php
+1
-3
tests/Silex/Tests/ControllerCollectionTest.php
tests/Silex/Tests/ControllerCollectionTest.php
+18
-0
No files found.
src/Silex/ControllerCollection.php
View file @
48727b4d
...
@@ -171,10 +171,8 @@ class ControllerCollection
...
@@ -171,10 +171,8 @@ class ControllerCollection
call_user_func_array
(
array
(
$this
->
defaultRoute
,
$method
),
$arguments
);
call_user_func_array
(
array
(
$this
->
defaultRoute
,
$method
),
$arguments
);
foreach
(
$this
->
controllers
as
$controller
)
{
foreach
(
$this
->
controllers
as
$controller
)
{
if
(
$controller
instanceof
Controller
)
{
call_user_func_array
(
array
(
$controller
,
$method
),
$arguments
);
call_user_func_array
(
array
(
$controller
,
$method
),
$arguments
);
}
}
}
return
$this
;
return
$this
;
}
}
...
...
tests/Silex/Tests/ControllerCollectionTest.php
View file @
48727b4d
...
@@ -176,6 +176,24 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
...
@@ -176,6 +176,24 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
$controller
=
new
ControllerCollection
(
$route
);
$controller
=
new
ControllerCollection
(
$route
);
$controller
->
bar
();
$controller
->
bar
();
}
}
public
function
testNestedCollectionRouteCallbacks
()
{
$cl1
=
new
ControllerCollection
(
new
MyRoute1
());
$cl2
=
new
ControllerCollection
(
new
MyRoute1
());
$c1
=
$cl2
->
match
(
'/c1'
,
function
()
{});
$cl1
->
mount
(
'/foo'
,
$cl2
);
$c2
=
$cl2
->
match
(
'/c2'
,
function
()
{});
$cl1
->
before
(
'before'
);
$c3
=
$cl2
->
match
(
'/c3'
,
function
()
{});
$cl1
->
flush
();
$this
->
assertEquals
(
array
(
'before'
),
$c1
->
getRoute
()
->
getOption
(
'_before_middlewares'
));
$this
->
assertEquals
(
array
(
'before'
),
$c2
->
getRoute
()
->
getOption
(
'_before_middlewares'
));
$this
->
assertEquals
(
array
(
'before'
),
$c3
->
getRoute
()
->
getOption
(
'_before_middlewares'
));
}
}
}
class
MyRoute1
extends
Route
class
MyRoute1
extends
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