8000 [FrameworkBundle] Removed deprecated code paths by nicolas-grekas · Pull Request #15695 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Removed deprecated code paths #15695

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

Merged
merged 1 commit into from
Sep 6, 2015
Merged
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
4 changes: 0 additions & 4 deletions src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,6 @@ protected function has($id)
*/
protected function get($id)
{
if ('request' === $id) {
@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);
}

return $this->container->get($id);
}

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 @@ -95,7 +85,6 @@ public function getConfigTreeBuilder()
->end()
;

$this->addCsrfSection($rootNode);
$this->addFormSection($rootNode);
$this->addEsiSection($rootNode);
$this->addSsiSection($rootNode);
Expand All @@ -115,23 +104,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 All @@ -141,13 +113,9 @@ private function addFormSection(ArrayNodeDefinition $rootNode)
->canBeEnabled()
->children()
->arrayNode('csrf_protection')
->treatFalseLike(array('enabled' => false))
->treatTrueLike(array('enabled' => true))
->treatNullLike(array('enabled' => true))
->addDefaultsIfNotSet()
->canBeEnabled()
->children()
->booleanNode('enabled')->defaultNull()->end() // defaults to framework.csrf_protection.enabled
->scalarNode('field_name')->defaultNull()->end()
->scalarNode('field_name')->defaultValue('_token')->end()
->end()
->end()
->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,9 @@ public function load(array $configs, ContainerBuilder $container)
if (!class_exists('Symfony\Component\Validator\Validation')) {
throw new LogicException('The Validator component is required to use the Form component.');
}

if ($this->isConfigEnabled($container, $config['form']['csrf_protection'])) {
$config['csrf_protection']['enabled'] = true;
}
}

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

if (isset($config['assets'])) {
$this->registerAssetsConfiguration($config['assets'], $container, $loader);
Expand Down Expand Up @@ -200,20 +196,12 @@ public function getConfiguration(array $config, ContainerBuilder $container)
private function registerFormConfiguration($config, ContainerBuilder $container, XmlFileLoader $loader)
{
$loader->load('form.xml');
if (null === $config['form']['csrf_protection']['enabled']) {
$config['form']['csrf_protection']['enabled'] = $config['csrf_protection']['enabled'];
}

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

$container->setParameter('form.type_extension.csrf.enabled', true);

if (null !== $config['form']['csrf_protection']['field_name']) {
$container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']);
} else {
$container->setParameter('form.type_extension.csrf.field_name', $config['csrf_protection']['field_name']);
}
$container->setParameter('form.type_extension.csrf.field_name', $config['form']['csrf_protection']['field_name']);
} else {
$container->setParameter('form.type_extension.csrf.enabled', false);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<xsd:all>
<xsd:element name="assets" type="assets" minOccurs="0" maxOccurs="1" />
<xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" />
<xsd:element name="csrf-protection" type="csrf_protection" minOccurs="0" maxOccurs="1" />
<xsd:element name="esi" type="esi" minOccurs="0" maxOccurs="1" />
<xsd:element name="fragments" type="fragments" minOccurs="0" maxOccurs="1" />
<xsd:element name="profiler" type="profiler" minOccurs="0" maxOccurs="1" />
Expand Down Expand Up @@ -55,11 +54,6 @@
<xsd:attribute name="field-name" type="xsd:string" />
</xsd:complexType>

<xsd:complexType name="csrf_protection">
<xsd:attribute name="enabled" type="xsd:boolean" />
<xsd:attribute name="field-name" type="xsd:string" />
</xsd:complexType>

<xsd:complexType name="esi">
<xsd:attribute name="enabled" type="xsd:boolean" />
</xsd:complexType>
Expand Down
17 changes: 0 additions & 17 deletions src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Security\Core\SecurityContext;

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

/**
* Returns the security context service.
*
* @deprecated since version 2.6, to be removed in 3.0.
*
* @return SecurityContext|null The security context
*/
public function getSecurity()
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);

if ($this->container->has('security.context')) {
return $this->container->get('security.context');
}
}

/**
* Returns the current user.
*
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,11 @@
*/
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.
*/
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 Down Expand Up @@ -71,15 +55,11 @@ public function getLocale()

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

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

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

/**
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 @@ -25,23 +24,9 @@ class SessionHelper extends Helper
protected $session;
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.
*/
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->session = $requestStack->getSession();
} elseif ($requestStack instanceof RequestStack) {
$this->requestStack = $requestStack;
} else {
throw new \InvalidArgumentException('RequestHelper only accepts a Request or a RequestStack instance.');
}
$this->requestStack = $requestStack;
}

/**
Expand Down
Loading
0