Skip to content

Commit 7d61c5a

Browse files
committed
feature #2202 deprecate template related options entirely (xabbuh)
This PR was squashed before being merged into the 2.x branch (closes #2202). Discussion ---------- deprecate template related options entirely Commits ------- ee45a94 deprecate the force_redirects option 15aa3a9 deprecate the default_engine option d1c9dca deprecate the templating service option
2 parents e41763e + ee45a94 commit 7d61c5a

File tree

27 files changed

+33
-482
lines changed

27 files changed

+33
-482
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ CHANGELOG
5151
`isPopulateDefaultVars()` methods of the `Controller\Annotations\View` class
5252
* deprecated the `setEngine()`, `setTemplate()`, `setTemplateData()`, `setTemplateVar()`, `getEngine()`,
5353
`getTemplate()`, `getTemplateData()`, and `getTemplateVar()` methods of the `View\View` class
54-
* deprecated not setting the `fos_rest.service.templating` and `fos_rest.view.default_engine` options
55-
* deprecated not setting the `fos_rest.view.force_redirects` option to the empty array
5654
* deprecated not enabling the `fos_rest.body_listener` option explicitly, it will be disabled by default
5755
in 3.0
5856
* deprecated the following options:
@@ -62,6 +60,9 @@ CHANGELOG
6260
* `fos_rest.exception.service`
6361
* `fos_rest.service.inflector`
6462
* `fos_rest.service.router`
63+
* `fos_rest.service.templating`
64+
* `fos_rest.view.default_engine`
65+
* `fos_rest.view.force_redirects`
6566
* `fos_rest.view.templating_formats`
6667

6768
* the following classes and interfaces are marked as `deprecated`, they will be removed in 3.0:

DependencyInjection/Configuration.php

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,8 @@ public function getConfigTreeBuilder(): TreeBuilder
153153
->children()
154154
->scalarNode('router')->defaultValue('router')->setDeprecated('The "%path%.%node%" configuration key has been deprecated in FOSRestBundle 2.8.')->end()
155155
->scalarNode('templating')
156-
->defaultValue(static function () {
157-
@trigger_error('Not setting the "fos_rest.service.templating" configuration option to "null" is deprecated since FOSRestBundle 2.8.', E_USER_DEPRECATED);
158-
159-
return 'templating';
160-
})
161-
->validate()
162-
->ifTrue(static function ($v) { return $v; })
163-
->then(static function ($v) {
164-
@trigger_error('Not setting the "fos_rest.service.templating" configuration option to "null" is deprecated since FOSRestBundle 2.8.', E_USER_DEPRECATED);
165-
166-
return $v;
167-
})
168-
->end()
156+
->defaultValue('templating')
157+
->setDeprecated('The "%path%.%node%" option is deprecated since FOSRestBundle 2.8.')
169158
->end()
170159
->scalarNode('serializer')->defaultNull()->end()
171160
->scalarNode('view_handler')->defaultValue('fos_rest.view_handler.default')->end()
@@ -235,21 +224,11 @@ private function addViewSection(ArrayNodeDefinition $rootNode)
235224
->addDefaultsIfNotSet()
236225
->children()
237226
->scalarNode('default_engine')
238-
->defaultValue(static function () {
239-
@trigger_error('Not setting the "fos_rest.view.default_engine" configuration option to "null" is deprecated since FOSRestBundle 2.8.', E_USER_DEPRECATED);
240-
241-
return 'twig';
242-
})
243-
->validate()
244-
->ifTrue(static function ($v) { return $v; })
245-
->then(static function ($v) {
246-
@trigger_error('Not setting the "fos_rest.view.default_engine" configuration option to "null" is deprecated since FOSRestBundle 2.8.', E_USER_DEPRECATED);
247-
248-
return $v;
249-
})
250-
->end()
227+
->setDeprecated('The "%path%.%node%" option has been deprecated in FOSRestBundle 2.8.')
228+
->defaultValue('twig')
251229
->end()
252230
->arrayNode('force_redirects')
231+
->setDeprecated('The "%path%.%node%" option has been deprecated in FOSRestBundle 2.8.')
253232
->useAttributeAsKey('name')
254233
->defaultValue(['html' => true])
255234
->prototype('boolean')->end()

DependencyInjection/FOSRestExtension.php

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use FOS\RestBundle\ErrorRenderer\SerializerErrorRenderer;
1515
use FOS\RestBundle\EventListener\ResponseStatusCodeListener;
1616
use FOS\RestBundle\Inflector\DoctrineInflector;
17-
use FOS\RestBundle\View\ViewHandler;
1817
use Symfony\Component\Config\FileLocator;
1918
use Symfony\Component\DependencyInjection\Alias;
2019
use Symfony\Component\DependencyInjection\ChildDefinition;
@@ -355,35 +354,20 @@ private function loadView(array $config, XmlFileLoader $loader, ContainerBuilder
355354

356355
$defaultViewHandler = $container->getDefinition('fos_rest.view_handler.default');
357356

358-
if ([] !== $config['view']['force_redirects']) {
359-
@trigger_error('Not setting the "fos_rest.view.force_redirects" configuration option to an empty array is deprecated since FOSRestBundle 2.8.', E_USER_DEPRECATED);
360-
}
361-
362-
if (null === $config['service']['templating'] && [] === $config['view']['force_redirects'] && null === $config['view']['default_engine']) {
363-
$defaultViewHandler->setFactory([ViewHandler::class, 'create']);
364-
$defaultViewHandler->setArguments([
365-
new Reference('fos_rest.router'),
366-
new Reference('fos_rest.serializer'),
367-
new Reference('request_stack'),
368-
$formats,
369-
$config['view']['failed_validation'],
370-
$config['view']['empty_content'],
371-
$config['view']['serialize_null'],
372-
]);
373-
} else {
374-
$defaultViewHandler->setArguments([
375-
new Reference('fos_rest.router'),
376-
new Reference('fos_rest.serializer'),
377-
new Reference('fos_rest.templating', ContainerInterface::NULL_ON_INVALID_REFERENCE),
378-
new Reference('request_stack'),
379-
$formats,
380-
$config['view']['failed_validation'],
381-
$config['view']['empty_content'],
382-
$config['view']['serialize_null'],
383-
$config['view']['force_redirects'],
384-
$config['view']['default_engine'],
385-
]);
386-
}
357+
$defaultViewHandler->setArguments([
358+
new Reference('fos_rest.router'),
359+
new Reference('fos_rest.serializer'),
360+
new Reference('fos_rest.templating', ContainerInterface::NULL_ON_INVALID_REFERENCE),
361+
new Reference('request_stack'),
362+
$formats,
363+
$config['view']['failed_validation'],
364+
$config['view']['empty_content'],
365+
$config['view']['serialize_null'],
366+
$config['view']['force_redirects'],
367+
$config['view']['default_engine'],
368+
[],
369+
false,
370+
]);
387371
}
388372

389373
private function loadException(array $config, XmlFileLoader $loader, ContainerBuilder $container)

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,6 @@ public function testExceptionCodesAcceptsIntegers()
6161
],
6262
'routing_loader' => false,
6363
'body_listener' => false,
64-
'service' => [
65-
'templating' => null,
66-
],
67-
'view' => [
68-
'default_engine' => null,
69-
],
7064
],
7165
]
7266
);
@@ -94,12 +88,6 @@ public function testThatResponseConstantsConvertedToCodes()
9488
],
9589
'routing_loader' => false,
9690
'body_listener' => false,
97-
'service' => [
98-
'templating' => null,
99-
],
100-
'view' => [
101-
'default_engine' => null,
102-
],
10391
];
10492

10593
$config = $this->processor->processConfiguration($this->configuration, [$config]);
@@ -133,12 +121,6 @@ public function testThatIfExceptionCodeIncorrectExceptionIsThrown($value)
133121
],
134122
'routing_loader' => false,
135123
'body_listener' => false,
136-
'service' => [
137-
'templating' => null,
138-
],
139-
'view' => [
140-
'default_engine' => null,
141-
],
142124
],
143125
]
144126
);
@@ -161,12 +143,6 @@ public function testLoadBadMessagesClassThrowsException()
161143
],
162144
'routing_loader' => false,
163145
'body_listener' => false,
164-
'service' => [
165-
'templating' => null,
166-
],
167-
'view' => [
168-
'default_engine' => null,
169-
],
170146
],
171147
]
172148
);
@@ -190,12 +166,6 @@ public function testLoadBadCodesClassThrowsException()
190166
],
191167
'routing_loader' => false,
192168
'body_listener' => false,
193-
'service' => [
194-
'templating' => null,
195-
],
196-
'view' => [
197-
'default_engine' => null,
198-
],
199169
],
200170
]
201171
);
@@ -225,12 +195,6 @@ public function testOverwriteFormatListenerRulesDoesNotMerge()
225195
],
226196
'routing_loader' => false,
227197
'body_listener' => false,
228-
'service' => [
229-
'templating' => null,
230-
],
231-
'view' => [
232-
'default_engine' => null,
233-
],
234198
],
235199
[
236200
'format_listener' => [

0 commit comments

Comments
 (0)