Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5fe3e61

Browse files
author
Hugo Hamon
committed
Removed request service occurrences.
1 parent 7170421 commit 5fe3e61

File tree

5 files changed

+13
-46
lines changed

5 files changed

+13
-46
lines changed

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -261,22 +261,6 @@ public function createFormBuilder($data = null, array $options = array())
261261
return $this->container->get('form.factory')->createBuilder('form', $data, $options);
262262
}
263263

264-
/**
265-
* Shortcut to return the request service.
266-
*
267-
* @return Request
268-
*
269-
* @deprecated Deprecated since version 2.4, to be removed in 3.0. Ask
270-
* Symfony to inject the Request object into your controller
271-
* method instead by type hinting it in the method's signature.
272-
*/
273-
public function getRequest()
274-
{
275-
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);
276-
277-
return $this->container->get('request_stack')->getCurrentRequest();
278-
}
279-
280264
/**
281265
* Shortcut to return the Doctrine Registry service.
282266
*

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,11 @@
3737
<argument type="collection" />
3838
</service>
3939

40-
<!--
41-
If you want to change the Request class, modify the code in
42-
your front controller (app.php) so that it passes an instance of
43-
YourRequestClass to the Kernel.
44-
This service definition only defines the scope of the request.
45-
It is used to check references scope.
46-
47-
This service is deprecated, you should use the request_stack service instead.
48-
-->
49-
<service id="request" scope="request" synthetic="true" synchronized="true" />
50-
5140
<service id="service_container" synthetic="true" />
5241

5342
<service id="kernel" synthetic="true" />
5443

55-
<service id="filesystem" class="%filesystem.class%"></service>
44+
<service id="filesystem" class="%filesystem.class%" />
5645

5746
<service id="file_locator" class="%file_locator.class%">
5847
<argument type="service" id="kernel" />

src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</service>
4545

4646
<service id="templating.asset.path_package" class="%templating.asset.path_package.class%" abstract="true">
47-
<argument type="service" id="request" />
47+
<argument type="expression">service('request_stack').getMasterRequest()</argument>
4848
<argument /> <!-- version -->
4949
<argument /> <!-- version format -->
5050
</service>
@@ -55,9 +55,8 @@
5555
<argument /> <!-- version format -->
5656
</service>
5757

58-
<service id="templating.asset.request_aware_package" class="Symfony\Component\Templating\Asset\PackageInterface" abstract="true">
59-
<factory service="templating.asset.package_factory" method="getPackage" />
60-
<argument type="service" id="request" strict="false" />
58+
<service id="templating.asset.request_aware_package" class="Symfony\Component\Templating\Asset\PackageInterface" factory-service="templating.asset.package_factory" factory-method="getPackage" abstract="true">
59+
<argument type="expression">service('request_stack').getCurrentRequest()</argument>
6160
<argument /> <!-- HTTP id -->
6261
<argument /> <!-- SSL id -->
6362
</service>

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginFormType.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\Form\FormError;
1717
use Symfony\Component\Form\FormEvents;
1818
use Symfony\Component\Form\FormEvent;
19-
use Symfony\Component\HttpFoundation\Request;
19+
use Symfony\Component\HttpFoundation\RequestStack;
2020
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
2121
use Symfony\Component\Security\Core\Security;
2222

@@ -29,18 +29,15 @@
2929
*/
3030
class UserLoginFormType extends AbstractType
3131
{
32-
private $request;
32+
private $requestStack;
3333

34-
/**
35-
* @param Request $request A request instance
36-
*/
37-
public function __construct(Request $request)
34+
public function __construct(RequestStack $requestStack)
3835
{
39-
$this->request = $request;
36+
$this->requestStack = $requestStack;
4037
}
4138

4239
/**
43-
* @see Symfony\Component\Form\AbstractType::buildForm()
40+
* {@inheritdoc}
4441
*/
4542
public function buildForm(FormBuilderInterface $builder, array $options)
4643
{
@@ -50,7 +47,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
5047
->add('_target_path', 'hidden')
5148
;
5249

53-
$request = $this->request;
50+
$request = $this->requestStack->getMasterRequest();
5451

5552
/* Note: since the Security component's form login listener intercepts
5653
* the POST request, this form will never really be bound to the
@@ -75,7 +72,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
7572
}
7673

7774
/**
78-
* @see Symfony\Component\Form\AbstractType::setDefaultOptions()
75+
* {@inheritdoc}
7976
*/
8077
public function setDefaultOptions(OptionsResolverInterface $resolver)
8178
{
@@ -89,7 +86,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
8986
}
9087

9188
/**
92-
* @see Symfony\Component\Form\FormTypeInterface::getName()
89+
* {@inheritdoc}
9390
*/
9491
public function getName()
9592
{

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CsrfFormLogin/config.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ imports:
44
services:
55
csrf_form_login.form.type:
66
class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\CsrfFormLoginBundle\Form\UserLoginFormType
7-
scope: request
8-
arguments:
9-
- @request
7+
arguments: [ @request_stack ]
108
tags:
119
- { name: form.type, alias: user_login }
1210

0 commit comments

Comments
 (0)