8000 [FrameworkBundle] Removed deprecated code paths · symfony/symfony@640b95a · GitHub
[go: up one dir, main page]

Skip to content

Commit 640b95a

Browse files
[FrameworkBundle] Removed deprecated code paths
1 parent eca45b7 commit 640b95a

39 files changed

+49
-533
lines changed

src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,6 @@ protected function has($id)
327327
*/
328328
protected function get($id)
329329
{
330-
if ('request' === $id) {
331-
@trigger_error('The "request" service is deprecated and will be removed in 3.0. Add a typehint for Symfony\\Component\\HttpFoundation\\Request to your controller parameters to retrieve the request instead.', E_USER_DEPRECATED);
332-
}
333-
334330
return $this->container->get($id);
335331
}
336332

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: 2 additions & 34 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')
@@ -95,7 +85,6 @@ public function getConfigTreeBuilder()
9585
->end()
9686
;
9787

98-
$this->addCsrfSection($rootNode);
9988
$this->addFormSection($rootNode);
10089
$this->addEsiSection($rootNode);
10190
$this->addSsiSection($rootNode);
@@ -115,23 +104,6 @@ public function getConfigTreeBuilder()
115104
return $treeBuilder;
116105
}
117106

118-
private function addCsrfSection(ArrayNodeDefinition $rootNode)
119-
{
120-
$rootNode
121-
->children()
122-
->arrayNode('csrf_protection')
123-
->canBeEnabled()
124-
->children()
125-
->scalarNode('field_name')
126-
->defaultValue('_token')
127-
->info('Deprecated since version 2.4, to be removed in 3.0. Use form.csrf_protection.field_name instead')
128-
->end()
129-
->end()
130-
->end()
131-
->end()
132-
;
133-
}
134-
135107
private function addFormSection(ArrayNodeDefinition $rootNode)
136108
{
137109
$rootNode
@@ -141,13 +113,9 @@ private function addFormSection(ArrayNodeDefinition $rootNode)
141113
->canBeEnabled()
142114
->children()
143115
->arrayNode('csrf_protection')
144-
->treatFalseLike(array('enabled' => false))
145-
->treatTrueLike(array('enabled' => true))
146-
->treatNullLike(array('enabled' => true))
147-
->addDefaultsIfNotSet()
116+
->canBeEnabled()
148117
->children()
149-
->booleanNode('enabled')->defaultNull()->end() // defaults to framework.csrf_protection.enabled
150-
->scalarNode('field_name')->defaultNull()->end()
118+
->scalarNode('field_name')->defaultValue('_token')->end()
151119
->end()
152120
->end()
153121
->end()

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,9 @@ public function load(array $configs, ContainerBuilder $container)
9797
if (!class_exists('Symfony\Component\Validator\Validation')) {
9898
throw new LogicException('The Validator component is required to use the Form component.');
9999
}
100-
101-
if ($this->isConfigEnabled($container, $config['form']['csrf_protection'])) {
102-
$config['csrf_protection']['enabled'] = true;
103-
}
104100
}
105101

106-
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
102+
$this->registerSecurityCsrfConfiguration($config['form']['csrf_protection'], $container, $loader);
107103

108104
if (isset($config['assets'])) {
109105
$this->registerAssetsConfiguration($config['assets'], $container, $loader);
@@ -200,20 +196,12 @@ public function getConfiguration(array $config, ContainerBuilder $container)
200196
private function registerFormConfiguration($config, ContainerBuilder $container, XmlFileLoader $loader)
201197
{
202198
$loader->load('form.xml');
203-
if (null === $config['form']['csrf_protection']['enabled']) {
204-
$config['form']['csrf_protection']['enabled'] = $config['csrf_protection']['enabled'];
205-
}
206199

207200
if ($this->isConfigEnabled($container, $config['form']['csrf_protection'])) {
208201
$loader->load('form_csrf.xml');
209202

210203
$container->setParameter('form.type_extension.csrf.enabled', true);
211-
212-
if (null !== $config['form']['csrf_protection']['field_name']) {
213-
$container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']);
214-
} else {
215-
$container->setParameter('form.type_extension.csrf.field_name', $config['csrf_protection']['field_name']);
216-
}
204+
$container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']);
217205
} else {
218206
$container->setParameter('form.type_extension.csrf.enabled', false);
219207
}

src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php

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

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
<xsd:all>
2121
<xsd:element name="assets" type="assets" minOccurs="0" maxOccurs="1" />
2222
<xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" />
23-
<xsd:element name="csrf-protection" type="csrf_protection" minOccurs="0" maxOccurs="1" />
2423
<xsd:element name="esi" type="esi" minOccurs="0" maxOccurs="1" />
2524
<xsd:element name="fragments" type="fragments" minOccurs="0" maxOccurs="1" />
2625
<xsd:element name="profiler" type="profiler" minOccurs="0" maxOccurs="1" />
@@ -55,11 +54,6 @@
5554
<xsd:attribute name="field-name" type="xsd:string" />
5655
</xsd:complexType>
5756

58-
<xsd:complexType name="csrf_protection">
59-
<xsd:attribute name="enabled" type="xsd:boolean" />
60-
<xsd:attribute name="field-name" type="xsd:string" />
61-
</xsd:complexType>
62-
6357
<xsd:complexType name="esi">
6458
<xsd:attribute name="enabled" type="xsd:boolean" />
6559
</xsd:complexType>

src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\DependencyInjection\ContainerInterface;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Session\Session;
17-
use Symfony\Component\Security\Core\SecurityContext;
1817

1918
/**
2019
* GlobalVariables is the entry point for Symfony global variables in PHP templates.
@@ -33,22 +32,6 @@ public function __construct(ContainerInterface $container)
3332
$this->container = $container;
3433
}
3534

36-
/**
37-
* Returns the security context service.
38-
*
39-
* @deprecated since version 2.6, to be removed in 3.0.
40-
*
41-
* @return SecurityContext|null The security context
42-
*/
43-
public function getSecurity()
44-
{
45-
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
46-
47-
if ($this->container->has('security.context')) {
48-
return $this->container->get('security.context');
49-
}
50-
}
51-
5235
/**
5336
* Returns the current user.
5437
*

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

Lines changed: 5 additions & 25 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,11 @@
2221
*/
2322
class RequestHelper extends Helper
2423
{
25-
protected $request;
2624
protected $requestStack;
2725

28-
/**
29-
* Constructor.
30-
*
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.
34-
*/
35-
public function __construct($requestStack)
26+
public function __construct(RequestStack $requestStack)
3627
{
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-
}
28+
$this->requestStack = $requestStack;
4529
}
4630

4731
/**
@@ -71,15 +55,11 @@ public function getLocale()
7155

7256
private function getRequest()
7357
{
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();
58+
if (!$this->requestStack->getCurrentRequest()) {
59+
throw new \LogicException('A Request must be available.');
8060
}
8161

82-
return $this->request;
62+
return $this->requestStack->getCurrentRequest();
8363
}
8464

8565
/**

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

Lines changed: 2 additions & 17 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
/**
@@ -25,23 +24,9 @@ class SessionHelper extends Helper
2524
protected $session;
2625
protected $requestStack;
2726

28-
/**
29-
* Constructor.
30-
*
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.
34-
*/
35-
public function __construct($requestStack)
27+
public function __construct(RequestStack $requestStack)
3628
{
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->session = $requestStack->getSession();
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-
}
29+
$this->requestStack = $requestStack;
4530
}
4631

4732
/**

0 commit comments

Comments
 (0)
0