Skip to content

Commit 67903e7

Browse files
committed
Drop deprecated code from Bundles & Bridges
1 parent e01a9a6 commit 67903e7

28 files changed

+32
-756
lines changed

src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -287,84 +287,6 @@ public function getValuesForChoices(array $entities)
287287
return parent::getValuesForChoices($entities);
288288
}
289289

290-
/**
291-
* Returns the indices corresponding to the given entities.
292-
*
293-
* @param array $entities
294-
*
295-
* @return array
296-
*
297-
* @see ChoiceListInterface
298-
*
299-
* @deprecated since version 2.4, to be removed in 3.0.
300-
*/
301-
public function getIndicesForChoices(array $entities)
302-
{
303-
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED);
304-
305-
// Performance optimization
306-
if (empty($entities)) {
307-
return array();
308-
}
309-
310-
if (!$this->loaded) {
311-
// Optimize performance for single-field identifiers. We already
312-
// know that the IDs are used as indices
313-
314-
// Attention: This optimization does not check choices for existence
315-
if ($this->idAsIndex) {
316-
$indices = array();
317-
318-
foreach ($entities as $i => $entity) {
319-
if ($entity instanceof $this->class) {
320-
// Make sure to convert to the right format
321-
$indices[$i] = $this->fixIndex(current($this->getIdentifierValues($entity)));
322-
}
323-
}
324-
325-
return $indices;
326-
}
327-
328-
$this->load();
329-
}
330-
331-
return parent::getIndicesForChoices($entities);
332-
}
333-
334-
/**
335-
* Returns the entities corresponding to the given values.
336-
*
337-
* @param array $values
338-
*
339-
* @return array
340-
*
341-
* @see ChoiceListInterface
342-
*
343-
* @deprecated since version 2.4, to be removed in 3.0.
344-
*/
345-
public function getIndicesForValues(array $values)
346-
{
347-
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED);
348-
349-
// Performance optimization
350-
if (empty($values)) {
351-
return array();
352-
}
353-
354-
if (!$this->loaded) {
355-
// Optimize performance for single-field identifiers.
356-
357-
// Attention: This optimization does not check values for existence
358-
if ($this->idAsIndex && $this->idAsValue) {
359-
return $this->fixIndices($values);
360-
}
361-
362-
$this->load();
363-
}
364-
365-
return parent::getIndicesForValues($values);
366-
}
367-
368290
/**
369291
* Creates a new unique index for this entity.
370292
*

src/Symfony/Bridge/Doctrine/Tests/DoctrineOrmTestCase.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -266,25 +266,4 @@ public function testInitShorthandEntityName()
266266

267267
$this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2)));
268268
}
269-
270-
/**
271-
* @group legacy
272-
*/
273-
public function testLegacyInitShorthandEntityName()
274-
{
275-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
276-
277-
$item1 = new SingleIntIdEntity(1, 'Foo');
278-
$item2 = new SingleIntIdEntity(2, 'Bar');
279-
280-
$this->em->persist($item1);
281-
$this->em->persist($item2);
282-
283-
$choiceList = new EntityChoiceList(
284-
$this->em,
285-
'SymfonyTestsDoctrine:SingleIntIdEntity'
286-
);
287-
288-
$this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
289-
}
290269
}

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/UnloadedEntityChoiceListSingleIntIdTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,4 @@ public function testGetIndicesForValuesIgnoresNonExistingValues()
2020
{
2121
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
2222
}
23-
24-
/**
25-
* @group legacy
26-
*/
27-
public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
28-
{
29-
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
30-
}
3123
}

src/Symfony/Bridge/Twig/AppVariable.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\HttpFoundation\Request;
1515
use Symfony\Component\HttpFoundation\RequestStack;
1616
use Symfony\Component\HttpFoundation\Session\Session;
17-
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1817
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1918

2019
/**

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/FragmentRendererPass.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@ public function getConfigTreeBuilder()
4343
$rootNode = $treeBuilder->root('framework');
4444

4545
$rootNode
46-
// Check deprecations before the config is processed to ensure
47-
// the setting has been explicitly defined in a configuration file.
48-
->beforeNormalization()
49-
->ifTrue(function ($v) { return isset($v['csrf_protection']['field_name']); })
50-
->then(function ($v) {
51-
trigger_error('The framework.csrf_protection.field_name configuration key is deprecated since version 2.4 and will be removed in 3.0. Use the framework.form.csrf_protection.field_name configuration key instead', E_USER_DEPRECATED);
52-
53-
return $v;
54-
})
55-
->end()
5646
->children()
5747
->scalarNode('secret')->end()
5848
->scalarNode('http_method_override')
@@ -98,7 +88,6 @@ public function getConfigTreeBuilder()
9888
->end()
9989
;
10090

101-
$this->addCsrfSection($rootNode);
10291
$this->addFormSection($rootNode);
10392
$this->addEsiSection($rootNode);
10493
$this->addSsiSection($rootNode);
@@ -118,23 +107,6 @@ public function getConfigTreeBuilder()
118107
return $treeBuilder;
119108
}
120109

121-
private function addCsrfSection(ArrayNodeDefinition $rootNode)
122-
{
123-
$rootNode
124-
->children()
125-
->arrayNode('csrf_protection')
126-
->canBeEnabled()
127-
->children()
128-
->scalarNode('field_name')
129-
->defaultValue('_token')
130-
->info('Deprecated since version 2.4, to be removed in 3.0. Use form.csrf_protection.field_name instead')
131-
->end()
132-
->end()
133-
->end()
134-
->end()
135-
;
136-
}
137-
138110
private function addFormSection(ArrayNodeDefinition $rootNode)
139111
{
140112
$rootNode
@@ -452,12 +424,6 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
452424
->info('validation configuration')
453425
->canBeEnabled()
454426
->children()
455-
->scalarNode('cache')
456-
->beforeNormalization()
457-
// Can be removed in 3.0, once ApcCache support is dropped
458-
->ifString()->then(function ($v) { return 'apc' === $v ? 'validator.mapping.cache.apc' : $v; })
459-
->end()
460-
->end()
461427
->booleanNode('enable_annotations')->defaultFalse()->end()
462428
->arrayNode('static_method')
463429
->defaultValue(array('loadValidatorMetadata'))
@@ -470,15 +436,6 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
470436
->end()
471437
->scalarNode('translation_domain')->defaultValue('validators')->end()
472438
->booleanNode('strict_email')->defaultFalse()->end()
473-
->enumNode('api')
474-
->info('Deprecated since version 2.7, to be removed in 3.0')
475-
->values(array('2.4', '2.5', '2.5-bc', 'auto'))
476-
->beforeNormalization()
477-
// XML/YAML parse as numbers, not as strings
478-
->ifTrue(function ($v) { return is_scalar($v); })
479-
->then(function ($v) { return (string) $v; })
480-
->end()
481-
->end()
482439
->end()
483440
->end()
484441
->end()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -763,12 +763,6 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
763763

764764
$validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache'])));
765765
}
766-
767-
// You can use this parameter to check the API version in your own
768-
// bundle extension classes
769-
// This is set to 2.5-bc for compatibility with Symfony 2.5 and 2.6.
770-
// @deprecated since version 2.7, to be removed in 3.0
771-
$container->setParameter('validator.api', '2.5-bc');
772766
}
773767

774768
private function getValidatorMappingFiles(ContainerBuilder $container)

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;
1313

1414
use Symfony\Component\Templating\Helper\Helper;
15-
use Symfony\Component\HttpFoundation\Request;
1615
use Symfony\Component\HttpFoundation\RequestStack;
1716

1817
/**
@@ -22,26 +21,16 @@
2221
*/
2322
class RequestHelper extends Helper
2423
{
25-
protected $request;
2624
protected $requestStack;
2725

2826
/**
2927
* Constructor.
3028
*
31-
* @param Request|RequestStack $requestStack A RequestStack instance or a Request instance
32-
*
33-
* @deprecated since version 2.5, passing a Request instance is deprecated and support for it will be removed in 3.0.
29+
* @param RequestStack $requestStack A RequestStack instance
3430
*/
35-
public function __construct($requestStack)
31+
public function __construct(RequestStack $requestStack)
3632
{
37-
if ($requestStack instanceof Request) {
38-
trigger_error('Since version 2.5, passing a Request instance into the '.__METHOD__.' is deprecated and support for it will be removed in 3.0. Inject a Symfony\Component\HttpFoundation\RequestStack instance instead.', E_USER_DEPRECATED);
39-
$this->request = $requestStack;
40-
} elseif ($requestStack instanceof RequestStack) {
41-
$this->requestStack = $requestStack;
42-
} else {
43-
throw new \InvalidArgumentException('RequestHelper only accepts a Request or a RequestStack instance.');
44-
}
33+
$this->requestStack = $requestStack;
4534
}
4635

4736
/**
@@ -52,7 +41,7 @@ public function __construct($requestStack)
5241
*
5342
* @return mixed
5443
*
55-
* @see Request::get()
44+
* @see \Symfony\Component\HttpFoundation\Request::get()
5645
*/
5746
public function getParameter($key, $default = null)
5847
{
@@ -69,26 +58,20 @@ public function getLocale()
6958
return $this->getRequest()->getLocale();
7059
}
7160

72-
private function getRequest()
73-
{
74-
if ($this->requestStack) {
75-
if (!$this->requestStack->getCurrentRequest()) {
76-
throw new \LogicException('A Request must be available.');
77-
}
78-
79-
return $this->requestStack->getCurrentRequest();
80-
}
81-
82-
return $this->request;
83-
}
84-
8561
/**
86-
* Returns the canonical name of this helper.
87-
*
88-
* @return string The canonical name
62+
* {@inheritdoc}
8963
*/
9064
public function getName()
9165
{
9266
return 'request';
9367
}
68+
69+
private function getRequest()
70+
{
71+
if ($currentRequest = $this->requestStack->getCurrentRequest()) {
72+
return $currentRequest;
73+
}
74+
75+
throw new \LogicException('A Request must be available.');
76+
}
9477
}

0 commit comments

Comments
 (0)