Skip to content

Drop deprecated code from Bundles & Bridges #14127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 0 additions & 78 deletions src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,84 +287,6 @@ public function getValuesForChoices(array $entities)
return parent::getValuesForChoices($entities);
}

/**
* Returns the indices corresponding to the given entities.
*
* @param array $entities
*
* @return array
*
* @see ChoiceListInterface
*
* @deprecated since version 2.4, to be removed in 3.0.
*/
public function getIndicesForChoices(array $entities)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED);

// Performance optimization
if (empty($entities)) {
return array();
}

if (!$this->loaded) {
// Optimize performance for single-field identifiers. We already
// know that the IDs are used as indices

// Attention: This optimization does not check choices for existence
if ($this->idAsIndex) {
$indices = array();

foreach ($entities as $i => $entity) {
if ($entity instanceof $this->class) {
// Make sure to convert to the right format
$indices[$i] = $this->fixIndex(current($this->getIdentifierValues($entity)));
}
}

return $indices;
}

$this->load();
}

return parent::getIndicesForChoices($entities);
}

/**
* Returns the entities corresponding to the given values.
*
* @param array $values
*
* @return array
*
* @see ChoiceListInterface
*
* @deprecated since version 2.4, to be removed in 3.0.
*/
public function getIndicesForValues(array $values)
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED);

// Performance optimization
if (empty($values)) {
return array();
}

if (!$this->loaded) {
// Optimize performance for single-field identifiers.

// Attention: This optimization does not check values for existence
if ($this->idAsIndex && $this->idAsValue) {
return $this->fixIndices($values);
}

$this->load();
}

return parent::getIndicesForValues($values);
}

/**
* Creates a new unique index for this entity.
*
Expand Down
34 changes: 0 additions & 34 deletions src/Symfony/Bridge/Doctrine/Tests/DoctrineOrmTestCase.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -266,25 +266,4 @@ public function testInitShorthandEntityName()

$this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2)));
}

/**
* @group legacy
*/
public function testLegacyInitShorthandEntityName()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$item1 = new SingleIntIdEntity(1, 'Foo');
$item2 = new SingleIntIdEntity(2, 'Bar');

$this->em->persist($item1);
$this->em->persist($item2);

$choiceList = new EntityChoiceList(
$this->em,
'SymfonyTestsDoctrine:SingleIntIdEntity'
);

$this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,4 @@ public function testGetIndicesForValuesIgnoresNonExistingValues()
{
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
}

/**
* @group legacy
*/
public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
{
$this->markTestSkipped('Non-existing values are not detected for unloaded choice lists.');
}
}
1 change: 0 additions & 1 deletion src/Symfony/Bridge/Twig/AppVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ public function getConfigTreeBuilder()
$rootNode = $treeBuilder->root('framework');

$rootNode
// Check deprecations before the config is processed to ensure
// the setting has been explicitly defined in a configuration file.
->beforeNormalization()
->ifTrue(function ($v) { return isset($v['csrf_protection']['field_name']); })
->then(function ($v) {
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);

return $v;
})
->end()
->children()
->scalarNode('secret')->end()
->scalarNode('http_method_override')
Expand Down Expand Up @@ -98,7 +88,6 @@ public function getConfigTreeBuilder()
->end()
;

$this->addCsrfSection($rootNode);
$this->addFormSection($rootNode);
$this->addEsiSection($rootNode);
$this->addSsiSection($rootNode);
Expand All @@ -118,23 +107,6 @@ public function getConfigTreeBuilder()
return $treeBuilder;
}

private function addCsrfSection(ArrayNodeDefinition $rootNode)
{
$rootNode
->children()
->arrayNode('csrf_protection')
->canBeEnabled()
->children()
->scalarNode('field_name')
->defaultValue('_token')
->info('Deprecated since version 2.4, to be removed in 3.0. Use form.csrf_protection.field_name instead')
->end()
->end()
->end()
->end()
;
}

private function addFormSection(ArrayNodeDefinition $rootNode)
{
$rootNode
Expand Down Expand Up @@ -452,12 +424,6 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
->info('validation configuration')
->canBeEnabled()
->children()
->scalarNode('cache')
->beforeNormalization()
// Can be removed in 3.0, once ApcCache support is dropped
->ifString()->then(function ($v) { return 'apc' === $v ? 'validator.mapping.cache.apc' : $v; })
->end()
->end()
->booleanNode('enable_annotations')->defaultFalse()->end()
->arrayNode('static_method')
->defaultValue(array('loadValidatorMetadata'))
Expand All @@ -470,15 +436,6 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
->end()
->scalarNode('translation_domain')->defaultValue('validators')->end()
->booleanNode('strict_email')->defaultFalse()->end()
->enumNode('api')
->info('Deprecated since version 2.7, to be removed in 3.0')
->values(array('2.4', '2.5', '2.5-bc', 'auto'))
->beforeNormalization()
// XML/YAML parse as numbers, not as strings
->ifTrue(function ($v) { return is_scalar($v); })
->then(function ($v) { return (string) $v; })
->end()
->end()
->end()
->end()
->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,12 +763,6 @@ private function registerValidationConfiguration(array $config, ContainerBuilder

$validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache'])));
}

// You can use this parameter to check the API version in your own
// bundle extension classes
// This is set to 2.5-bc for compatibility with Symfony 2.5 and 2.6.
// @deprecated since version 2.7, to be removed in 3.0
$container->setParameter('validator.api', '2.5-bc');
}

private function getValidatorMappingFiles(ContainerBuilder $container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;

use Symfony\Component\Templating\Helper\Helper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

/**
Expand All @@ -22,26 +21,16 @@
*/
class RequestHelper extends Helper
{
protected $request;
protected $requestStack;

/**
* Constructor.
*
* @param Request|RequestStack $requestStack A RequestStack instance or a Request instance
*
* @deprecated since version 2.5, passing a Request instance is deprecated and support for it will be removed in 3.0.
* @param RequestStack $requestStack A RequestStack instance
*/
public function __construct($requestStack)
public function __construct(RequestStack $requestStack)
{
if ($requestStack instanceof Request) {
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);
$this->request = $requestStack;
} elseif ($requestStack instanceof RequestStack) {
$this->requestStack = $requestStack;
} else {
throw new \InvalidArgumentException('RequestHelper only accepts a Request or a RequestStack instance.');
}
$this->requestStack = $requestStack;
}

/**
Expand All @@ -52,7 +41,7 @@ public function __construct($requestStack)
*
* @return mixed
*
* @see Request::get()
* @see \Symfony\Component\HttpFoundation\Request::get()
*/
public function getParameter($key, $default = null)
{
Expand All @@ -69,26 +58,20 @@ public function getLocale()
return $this->getRequest()->getLocale();
}

private function getRequest()
{
if ($this->requestStack) {
if (!$this->requestStack->getCurrentRequest()) {
throw new \LogicException('A Request must be available.');
}

return $this->requestStack->getCurrentRequest();
}

return $this->request;
}

/**
* Returns the canonical name of this helper.
*
* @return string The canonical name
* {@inheritdoc}
*/
public function getName()
{
return 'request';
}

private function getRequest()
{
if ($currentRequest = $this->requestStack->getCurrentRequest()) {
return $currentRequest;
}

throw new \LogicException('A Request must be available.');
}
}
Loading