From ebc22f5be543304c04415af794e6368deed125ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gildas=20Qu=C3=A9m=C3=A9ner?= Date: Fri, 6 Sep 2013 11:07:46 +0200 Subject: [PATCH 01/10] [FrameworkBundle] Added configuration for additionnal request formats --- .../DependencyInjection/Configuration.php | 24 ++++++ .../FrameworkExtension.php | 18 ++++ .../AddRequestFormatsListener.php | 45 ++++++++++ .../Resources/config/request.xml | 17 ++++ .../AddRequestFormatsListenerTest.php | 82 +++++++++++++++++++ 5 files changed, 186 insertions(+) create mode 100644 src/Symfony/Bundle/FrameworkBundle/EventListener/AddRequestFormatsListener.php create mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/EventListener/AddRequestFormatsListenerTest.php diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 0df083a6e4c55..09122feff8074 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -84,6 +84,7 @@ public function getConfigTreeBuilder() $this->addProfilerSection($rootNode); $this->addRouterSection($rootNode); $this->addSessionSection($rootNode); + $this->addRequestSection($rootNode); $this->addTemplatingSection($rootNode); $this->addTranslatorSection($rootNode); $this->addValidationSection($rootNode); @@ -228,6 +229,29 @@ private function addSessionSection(ArrayNodeDefinition $rootNode) ; } + private function addRequestSection(ArrayNodeDefinition $rootNode) + { + $rootNode + ->children() + ->arrayNode('request') + ->info('request configuration') + ->canBeUnset() + ->children() + ->arrayNode('additionnal_formats') + ->prototype('array') + ->beforeNormalization() + ->ifTrue(function($v) { return !is_array($v); }) + ->then(function($v) { return array($v); }) + ->end() + ->prototype('scalar')->end() + ->end() + ->end() + ->end() + ->end() + ->end() + ; + } + private function addTemplatingSection(ArrayNodeDefinition $rootNode) { $organizeUrls = function($urls) { diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index f0460c1a85ff6..b17aac53cbb75 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -81,6 +81,10 @@ public function load(array $configs, ContainerBuilder $container) $this->registerSessionConfiguration($config['session'], $container, $loader); } + if (isset($config['request'])) { + $this->registerRequestConfiguration($config['request'], $container, $loader); + } + if ($this->isConfigEnabled($container, $config['form'])) { $this->registerFormConfiguration($config, $container, $loader); $config['validation']['enabled'] = true; @@ -347,6 +351,20 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c } } + /** + * Loads the request configuration. + * + * @param array $config A session configuration array + * @param ContainerBuilder $container A ContainerBuilder instance + * @param XmlFileLoader $loader An XmlFileLoader instance + */ + private function registerRequestConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) + { + $container->setParameter('request.additionnal_formats', $config['additionnal_formats']); + + $loader->load('request.xml'); + } + /** * Loads the templating configuration. * diff --git a/src/Symfony/Bundle/FrameworkBundle/EventListener/AddRequestFormatsListener.php b/src/Symfony/Bundle/FrameworkBundle/EventListener/AddRequestFormatsListener.php new file mode 100644 index 0000000000000..4555979226ad1 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/EventListener/AddRequestFormatsListener.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\EventListener; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpKernel\KernelEvents; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; + +/** + * Set additionnal formats into the request + * + * @author Gildas Quemener + */ +class AddRequestFormatsListener implements EventSubscriberInterface +{ + protected $formats; + + public function __construct(array $formats) + { + $this->formats = $formats; + } + + public function onKernelRequest(GetResponseEvent $event) + { + foreach ($this->formats as $format => $mimeTypes) { + $event->getRequest()->setFormat($format, $mimeTypes); + } + } + + public static function getSubscribedEvents() + { + return array( + KernelEvents::REQUEST => 'onKernelRequest', + ); + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml new file mode 100644 index 0000000000000..e5a9ac69866b7 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml @@ -0,0 +1,17 @@ + + + + + + Symfony\Bundle\FrameworkBundle\EventListener\AddRequestFormatsListener + + + + + + %request.additionnal_formats% + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/EventListener/AddRequestFormatsListenerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/EventListener/AddRequestFormatsListenerTest.php new file mode 100644 index 0000000000000..b8482ddca4544 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/EventListener/AddRequestFormatsListenerTest.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\EventListener; + +use Symfony\Bundle\FrameworkBundle\EventListener\AddRequestFormatsListener; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\KernelEvents; + +/** + * Test AddRequestFormatsListener class + * + * @author Gildas Quemener + */ +class AddRequestFormatsListenerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var AddRequestFormatsListener + */ + private $listener; + + protected function setUp() + { + $this->listener = new AddRequestFormatsListener(array('csv' => array('text/csv', 'text/plain'))); + } + + protected function tearDown() + { + $this->listener = null; + } + + public function testIsAnEventSubscriber() + { + $this->assertInstanceOf('Symfony\Component\EventDispatcher\EventSubscriberInterface', $this->listener); + } + + public function testRegisteredEvent() + { + $this->assertEquals(array( + KernelEvents::REQUEST => 'onKernelRequest', + ), AddRequestFormatsListener::getSubscribedEvents()); + } + + public function testSetAdditionnalFormats() + { + $request = $this->getRequestMock(); + $event = $this->getGetResponseEventMock($request); + + $request->expects($this->once()) + ->method('setFormat') + ->with('csv', array('text/csv', 'text/plain')); + + $this->listener->onKernelRequest($event); + } + + protected function getRequestMock() + { + return $this->getMock('Symfony\Component\HttpFoundation\Request'); + } + + protected function getGetResponseEventMock(Request $request) + { + $event = $this + ->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') + ->disableOriginalConstructor() + ->getMock(); + + $event->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($request)); + + return $event; + } +} From c50d28401dc1121c1da448192d8bb490b273cb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gildas=20Qu=C3=A9m=C3=A9ner?= Date: Fri, 6 Sep 2013 12:50:52 +0200 Subject: [PATCH 02/10] [FrameworkBundle] Fixed mispelled "additional" word --- .../FrameworkBundle/DependencyInjection/Configuration.php | 2 +- .../FrameworkBundle/DependencyInjection/FrameworkExtension.php | 2 +- .../FrameworkBundle/EventListener/AddRequestFormatsListener.php | 2 +- src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 09122feff8074..30e0ef3639651 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -237,7 +237,7 @@ private function addRequestSection(ArrayNodeDefinition $rootNode) ->info('request configuration') ->canBeUnset() ->children() - ->arrayNode('additionnal_formats') + ->arrayNode('additional_formats') ->prototype('array') ->beforeNormalization() ->ifTrue(function($v) { return !is_array($v); }) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index b17aac53cbb75..7f3d84e062514 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -360,7 +360,7 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c */ private function registerRequestConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { - $container->setParameter('request.additionnal_formats', $config['additionnal_formats']); + $container->setParameter('request.additional_formats', $config['additional_formats']); $loader->load('request.xml'); } diff --git a/src/Symfony/Bundle/FrameworkBundle/EventListener/AddRequestFormatsListener.php b/src/Symfony/Bundle/FrameworkBundle/EventListener/AddRequestFormatsListener.php index 4555979226ad1..51318f13f66e3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/EventListener/AddRequestFormatsListener.php +++ b/src/Symfony/Bundle/FrameworkBundle/EventListener/AddRequestFormatsListener.php @@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\Event\GetResponseEvent; /** - * Set additionnal formats into the request + * Set additional formats into the request * * @author Gildas Quemener */ diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml index e5a9ac69866b7..c87013c2ea0f0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml @@ -11,7 +11,7 @@ - %request.additionnal_formats% + %request.additional_formats% From f019dec6339342c196fce8d7332e0cd36922cdcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gildas=20Qu=C3=A9m=C3=A9ner?= Date: Fri, 6 Sep 2013 13:01:39 +0200 Subject: [PATCH 03/10] [FrameworkBundle] Fixed xml configuration when adding request formats --- .../Bundle/FrameworkBundle/DependencyInjection/Configuration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 30e0ef3639651..ae0a35019a813 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -236,6 +236,7 @@ private function addRequestSection(ArrayNodeDefinition $rootNode) ->arrayNode('request') ->info('request configuration') ->canBeUnset() + ->fixXmlConfig('additionnal_format') ->children() ->arrayNode('additional_formats') ->prototype('array') From f92b1885f6a8839b9bad69788d64b743ad16ad46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gildas=20Qu=C3=A9m=C3=A9ner?= Date: Fri, 6 Sep 2013 14:06:56 +0200 Subject: [PATCH 04/10] [FrameworkBundle] Added request tag inside FrameworkBundle xsd --- .../DependencyInjection/Configuration.php | 2 +- .../Resources/config/schema/symfony-1.0.xsd | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index ae0a35019a813..caadcd68c0c5f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -236,7 +236,7 @@ private function addRequestSection(ArrayNodeDefinition $rootNode) ->arrayNode('request') ->info('request configuration') ->canBeUnset() - ->fixXmlConfig('additionnal_format') + ->fixXmlConfig('additional-format') ->children() ->arrayNode('additional_formats') ->prototype('array') diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index 4b235051f82d5..ab10377c8b6c1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -15,6 +15,7 @@ + @@ -93,6 +94,19 @@ + + + + + + + + + + + + + From 3cab8e2c9eec242eff9daec2770654b778bf4bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gildas=20Qu=C3=A9m=C3=A9ner?= Date: Sat, 7 Sep 2013 16:35:25 +0200 Subject: [PATCH 05/10] [FrameworkBundle] Removed top level id of format listener --- .../Bundle/FrameworkBundle/Resources/config/request.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml index c87013c2ea0f0..0170c95c43120 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/request.xml @@ -5,11 +5,11 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - Symfony\Bundle\FrameworkBundle\EventListener\AddRequestFormatsListener + Symfony\Bundle\FrameworkBundle\EventListener\AddRequestFormatsListener - + %request.additional_formats% From 2c5adea690429996a908dc29714c120c4eda4e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gildas=20Qu=C3=A9m=C3=A9ner?= Date: Sat, 7 Sep 2013 16:36:07 +0200 Subject: [PATCH 06/10] [FrameworkBundle] Fixed xml schema for embedding mime-types into format --- .../FrameworkBundle/Resources/config/schema/symfony-1.0.xsd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index ab10377c8b6c1..3cfddc07cfec1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -101,9 +101,9 @@ - - - + + + From 5165d1040cdb67ac9716be8118aa97a412189b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gildas=20Qu=C3=A9m=C3=A9ner?= Date: Sat, 7 Sep 2013 16:42:14 +0200 Subject: [PATCH 07/10] [FrameworkBundle] Load the formats listener only if some are configured --- .../DependencyInjection/FrameworkExtension.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 7f3d84e062514..16a38175bd5c5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -360,9 +360,10 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c */ private function registerRequestConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { - $container->setParameter('request.additional_formats', $config['additional_formats']); - - $loader->load('request.xml'); + if ($config['additional_formats']) { + $container->setParameter('request.additional_formats', $config['additional_formats']); + $loader->load('request.xml'); + } } /** From b41388e6336ab9a8dffd105ff8b37f8792391732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gildas=20Qu=C3=A9m=C3=A9ner?= Date: Sat, 7 Sep 2013 17:24:58 +0200 Subject: [PATCH 08/10] [FrameworkBundle] Added config fixtures for request key --- .../DependencyInjection/Configuration.php | 3 ++- .../Tests/DependencyInjection/Fixtures/php/full.php | 13 ++++++++++++- .../Tests/DependencyInjection/Fixtures/xml/full.xml | 6 ++++++ .../Tests/DependencyInjection/Fixtures/yml/full.yml | 4 ++++ .../DependencyInjection/FrameworkExtensionTest.php | 8 ++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index caadcd68c0c5f..2ce9ca17ce194 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -236,9 +236,10 @@ private function addRequestSection(ArrayNodeDefinition $rootNode) ->arrayNode('request') ->info('request configuration') ->canBeUnset() - ->fixXmlConfig('additional-format') + ->fixXmlConfig('additional_format') ->children() ->arrayNode('additional_formats') + ->useAttributeAsKey('name') ->prototype('array') ->beforeNormalization() ->ifTrue(function($v) { return !is_array($v); }) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php index c4eff9349228e..f65c5536774cb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -70,5 +70,16 @@ 'debug' => true, 'file_cache_dir' => '%kernel.cache_dir%/annotations', ), - 'ide' => 'file%%link%%format' + 'ide' => 'file%%link%%format', + 'request' => array( + 'additional_formats' => array( + 'csv' => array( + 'text/csv', + 'text/plain', + ), + 'pdf' => array( + 'application/pdf' + ) + ) + ) )); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml index 8fd3e9b6528a0..57f6092c250e5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -36,5 +36,11 @@ + + + text/csv + text/plain + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml index d013063916c38..eca9a788b944d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml @@ -55,3 +55,7 @@ framework: debug: true file_cache_dir: %kernel.cache_dir%/annotations ide: file%%link%%format + request: + additional_formats: + csv: ['text/csv', 'text/plain'] + pdf: 'application/pdf' diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 4df785d6c7117..c5c9b108e6aeb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -123,6 +123,14 @@ public function testNullSessionHandler() $this->assertNull($container->getDefinition('session.storage.php_bridge')->getArgument(0)); } + public function testRequest() + { + $container = $this->createContainerFromFile('full'); + + $this->assertTrue($container->hasDefinition('request.add_request_formats_listener'), '->registerRequestConfiguration() loads request.xml'); + $this->assertEquals(array('csv' => array('text/csv', 'text/plain'), 'pdf' => array('application/pdf')), $container->getParameter('request.additional_formats')); + } + public function testTemplating() { $container = $this->createContainerFromFile('full'); From 05ccbdb28938cf99ce83b7213c784dd3f1f48e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gildas=20Qu=C3=A9m=C3=A9ner?= Date: Sat, 7 Sep 2013 17:25:58 +0200 Subject: [PATCH 09/10] [FrameworkBundle] Added config fixtures for empty request formats --- .../DependencyInjection/Fixtures/php/request.php | 7 +++++++ .../DependencyInjection/Fixtures/xml/request.xml | 12 ++++++++++++ .../DependencyInjection/Fixtures/yml/request.yml | 3 +++ .../DependencyInjection/FrameworkExtensionTest.php | 7 +++++++ 4 files changed, 29 insertions(+) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/request.xml create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/request.yml diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php new file mode 100644 index 0000000000000..06624e29b0f16 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/request.php @@ -0,0 +1,7 @@ +loadFromExtension('framework', array( + 'request' => array( + 'additional_formats' => array(), + ), +)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/request.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/request.xml new file mode 100644 index 0000000000000..49849c2a381d1 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/request.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/request.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/request.yml new file mode 100644 index 0000000000000..50a8e227cefd4 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/request.yml @@ -0,0 +1,3 @@ +framework: + request: + additional_formats: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index c5c9b108e6aeb..be56ee3459b70 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -131,6 +131,13 @@ public function testRequest() $this->assertEquals(array('csv' => array('text/csv', 'text/plain'), 'pdf' => array('application/pdf')), $container->getParameter('request.additional_formats')); } + public function testEmptyAdditionlRequestFormats() + { + $container = $this->createContainerFromFile('request'); + + $this->assertFalse($container->hasDefinition('request.add_request_formats_listener'), '->registerRequestConfiguration() does not load request.xml when no additional request formats are configured'); + } + public function testTemplating() { $container = $this->createContainerFromFile('full'); From f7690765f460f0e2604b6364cdaecc9dd7b6ca9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gildas=20Qu=C3=A9m=C3=A9ner?= Date: Sat, 7 Sep 2013 17:30:50 +0200 Subject: [PATCH 10/10] [FrameworkBundle] Added missing php doc --- .../EventListener/AddRequestFormatsListener.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/EventListener/AddRequestFormatsListener.php b/src/Symfony/Bundle/FrameworkBundle/EventListener/AddRequestFormatsListener.php index 51318f13f66e3..6ba098e0183df 100644 --- a/src/Symfony/Bundle/FrameworkBundle/EventListener/AddRequestFormatsListener.php +++ b/src/Symfony/Bundle/FrameworkBundle/EventListener/AddRequestFormatsListener.php @@ -22,13 +22,24 @@ */ class AddRequestFormatsListener implements EventSubscriberInterface { + /** + * @var array + */ protected $formats; + /** + * @param array $formats + */ public function __construct(array $formats) { $this->formats = $formats; } + /** + * Set additionnal request formats + * + * @param GetResponseEvent $event + */ public function onKernelRequest(GetResponseEvent $event) { foreach ($this->formats as $format => $mimeTypes) { @@ -36,6 +47,9 @@ public function onKernelRequest(GetResponseEvent $event) } } + /** + * {@inheritdoc} + */ public static function getSubscribedEvents() { return array( pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy