Skip to content

Commit db7d9a1

Browse files
authored
Merge pull request #2410 from flohw/3.x
fix: Sensio extra bundle TemplateListener invocation before view response listener and serialization
2 parents fa0f68b + 11e5491 commit db7d9a1

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

EventListener/ViewResponseListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public static function getSubscribedEvents(): array
170170
{
171171
return [
172172
KernelEvents::CONTROLLER => 'onKernelController',
173-
KernelEvents::VIEW => ['onKernelView', -128],
173+
KernelEvents::VIEW => ['onKernelView', 30],
174174
];
175175
}
176176

Tests/Functional/Bundle/TestBundle/Controller/ArticleController.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,26 @@ public function cpostAction(Request $request)
3232
}
3333

3434
/**
35-
* @Get("/articles.{_format}", name="get_article", defaults={"_format": "html"})
35+
* @Get("/articles.{_format}", name="get_articles", defaults={"_format": "html"})
3636
*
3737
* @View()
3838
*/
39-
#[Get(path: '/articles.{_format}', name: 'get_article', defaults: ['_format' => 'html'])]
39+
#[Get(path: '/articles.{_format}', name: 'get_articles', defaults: ['_format' => 'html'])]
4040
#[View]
4141
public function cgetAction()
4242
{
4343
return $this->view();
4444
}
45+
46+
/**
47+
* @Get("/articles/{id}.{_format}", name="get_article", defaults={"_format": "html"})
48+
*
49+
* @View()
50+
*/
51+
#[Get(path: '/articles/{id}.{_format}', name: 'get_article', defaults: ['_format' => 'html'])]
52+
#[View]
53+
public function cgetSingleAction(int $id)
54+
{
55+
return ['id' => $id];
56+
}
4557
}

Tests/Functional/ViewResponseListenerTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,12 @@ public function testRedirect()
3535
$this->assertSame('http://localhost/hello/Post%201', $client->getResponse()->headers->get('location'));
3636
$this->assertStringNotContainsString('fooo', $client->getResponse()->getContent());
3737
}
38+
39+
public function testControllerReturnsView()
40+
{
41+
$client = $this->createClient(['test_case' => 'ViewResponseListener']);
42+
$client->request('GET', '/articles.json');
43+
44+
$this->assertTrue($client->getResponse()->isSuccessful());
45+
}
3846
}

Tests/Functional/app/ViewResponseListener/bundles.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
$bundles = [
1313
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
14+
new \Symfony\Bundle\TwigBundle\TwigBundle(),
1415
new \FOS\RestBundle\FOSRestBundle(),
1516
new \FOS\RestBundle\Tests\Functional\Bundle\TestBundle\TestBundle(),
1617
];

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
xsi:noNamespaceSchemaLocation=".phpunit/phpunit.xsd"
88
>
99
<php>
10-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=104&amp;max[indirect]=243"/>
10+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=120&amp;max[indirect]=243"/>
1111
<env name="SYMFONY_PHPUNIT_VERSION" value="9.6"/>
1212
<ini name="error_reporting" value="-1"/>
1313
<server name="SHELL_VERBOSITY" value="-1"/>

0 commit comments

Comments
 (0)