diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php index f42d134e29..beb25698b9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php @@ -261,22 +261,6 @@ class Controller extends ContainerAware return $this->container->get('form.factory')->createBuilder('form', $data, $options); } - /** - * Shortcut to return the request service. - * - * @return Request - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. Ask - * Symfony to inject the Request object into your controller - * method instead by type hinting it in the method's signature. - */ - public function getRequest() - { - trigger_error('The "getRequest" method of the base "Controller" class has been deprecated since Symfony 2.4 and will be removed in 3.0. The only reliable way to get the "Request" object is to inject it in the action method.', E_USER_DEPRECATED); - - return $this->container->get('request_stack')->getCurrentRequest(); - } - /** * Shortcut to return the Doctrine Registry service. * diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml index 4457dbb276..2c3c6ea312 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml @@ -37,22 +37,11 @@ - - - - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml index 6e482f8573..7cfcc09863 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml @@ -44,7 +44,7 @@ - + service('request_stack').getMasterRequest() @@ -55,9 +55,8 @@ - - - + + service('request_stack').getMasterRequest() diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php index 6928e6868b..c615ef5fd6 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php @@ -16,7 +16,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvent; -use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\OptionsResolver\OptionsResolverInterface; use Symfony\Component\Security\Core\Security; @@ -29,18 +29,15 @@ use Symfony\Component\Security\Core\Security; */ class UserLoginFormType extends AbstractType { - private $request; + private $requestStack; - /** - * @param Request $request A request instance - */ - public function __construct(Request $request) + public function __construct(RequestStack $requestStack) { - $this->request = $request; + $this->requestStack = $requestStack; } /** - * @see Symfony\Component\Form\AbstractType::buildForm() + * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { @@ -50,7 +47,7 @@ class UserLoginFormType extends AbstractType ->add('_target_path', 'hidden') ; - $request = $this->request; + $request = $this->requestStack->getCurrentRequest(); /* Note: since the Security component's form login listener intercepts * the POST request, this form will never really be bound to the @@ -75,7 +72,7 @@ class UserLoginFormType extends AbstractType } /** - * @see Symfony\Component\Form\AbstractType::setDefaultOptions() + * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { @@ -89,7 +86,7 @@ class UserLoginFormType extends AbstractType } /** - * @see Symfony\Component\Form\FormTypeInterface::getName() + * {@inheritdoc} */ public function getName() { diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml index e1e2b0e883..8b0920df37 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml @@ -4,9 +4,7 @@ imports: services: csrf_form_login.form.type: class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginFormType - scope: request - arguments: - - @request + arguments: [ @request_stack ] tags: - { name: form.type, alias: user_login }