Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[3.0] [FrameworkBundle] removed request service occurrences. #12460

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
Jan 2, 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
16 changes: 0 additions & 16 deletions 16 src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
13 changes: 1 addition & 12 deletions 13 src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,11 @@
<argument type="collection" />
</service>

<!--
If you want to change the Request class, modify the code in
your front controller (app.php) so that it passes an instance of
YourRequestClass to the Kernel.
This service definition only defines the scope of the request.
It is used to check references scope.

This service is deprecated, you should use the request_stack service instead.
-->
<service id="request" scope="request" synthetic="true" synchronized="true" />

<service id="service_container" synthetic="true" />

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

<service id="filesystem" class="%filesystem.class%"></service>
<service id="filesystem" class="%filesystem.class%" />

<service id="file_locator" class="%file_locator.class%">
<argument type="service" id="kernel" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</service>

<service id="templating.asset.path_package" class="%templating.asset.path_package.class%" abstract="true">
<argument type="service" id="request" />
<argument type="expression">service('request_stack').getMasterRequest()</argument>
<argument /> <!-- version -->
<argument /> <!-- version format -->
</service>
Expand All @@ -55,9 +55,8 @@
<argument /> <!-- version format -->
</service>

<service id="templating.asset.request_aware_package" class="Symfony\Component\Templating\Asset\PackageInterface" abstract="true">
<factory service="templating.asset.package_factory" method="getPackage" />
<argument type="service" id="request" strict="false" />
<service id="templating.asset.request_aware_package" class="Symfony\Component\Templating\Asset\PackageInterface" factory-service="templating.asset.package_factory" factory-method="getPackage" abstract="true">
<argument type="expression">service('request_stack').getMasterRequest()</argument>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break if the master request is not available (in the CLI for instance). It would be better to inject the RequestStack itself.

<argument /> <!-- HTTP id -->
<argument /> <!-- SSL id -->
</service>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change could even be done in older branches to simplify merging between branches, given it is in our functional tests.

{
$this->request = $request;
$this->requestStack = $requestStack;
}

/**
* @see Symfony\Component\Form\AbstractType::buildForm()
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
Expand All @@ -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
Expand All @@ -75,7 +72,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

/**
* @see Symfony\Component\Form\AbstractType::setDefaultOptions()
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
Expand All @@ -89,7 +86,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
}

/**
* @see Symfony\Component\Form\FormTypeInterface::getName()
* {@inheritdoc}
*/
public function getName()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.