diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php index f42d134e295eb..beb25698b967d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php @@ -261,22 +261,6 @@ public function createFormBuilder($data = null, array $options = array()) 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 4457dbb27669c..2c3c6ea312a62 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 6e482f8573e51..7cfcc0986324b 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 6928e6868b09c..c615ef5fd6106 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\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 @@ */ 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 @@ public function buildForm(FormBuilderInterface $builder, array $options) ->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 @@ public function buildForm(FormBuilderInterface $builder, array $options) } /** - * @see Symfony\Component\Form\AbstractType::setDefaultOptions() + * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { @@ -89,7 +86,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) } /** - * @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 e1e2b0e883933..8b0920df37202 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 }