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
974b49d1
Commit
974b49d1
authored
Jan 19, 2015
by
Dave Marshall
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow view listeners to be "skipped" by returning null
parent
50150276
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
src/Silex/ViewListenerWrapper.php
src/Silex/ViewListenerWrapper.php
+1
-1
tests/Silex/Tests/ApplicationTest.php
tests/Silex/Tests/ApplicationTest.php
+18
-0
No files found.
src/Silex/ViewListenerWrapper.php
View file @
974b49d1
...
...
@@ -49,7 +49,7 @@ class ViewListenerWrapper
if
(
$response
instanceof
Response
)
{
$event
->
setResponse
(
$response
);
}
else
{
}
else
if
(
null
!==
$response
)
{
$event
->
setControllerResult
(
$response
);
}
}
...
...
tests/Silex/Tests/ApplicationTest.php
View file @
974b49d1
...
...
@@ -663,6 +663,24 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
'Hello world'
,
$response
->
getContent
());
}
public
function
testViewListenersResponsesAreNotUsedIfNull
()
{
$app
=
new
Application
();
$app
->
get
(
'/foo'
,
function
()
{
return
'Hello world'
;
});
$app
->
view
(
function
(
$view
)
{
return
'Hello view listener'
;
});
$app
->
view
(
function
(
$view
)
{
return
null
;
});
$response
=
$app
->
handle
(
Request
::
create
(
'/foo'
));
$this
->
assertEquals
(
'Hello view listener'
,
$response
->
getContent
());
}
}
class
FooController
...
...
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