This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Fabien Potencier 473263a00b feature #18510 Added a SecurityUserValueResolver for controllers (iltar)
This PR was merged into the 3.2-dev branch.

Discussion
----------

Added a SecurityUserValueResolver for controllers

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | ~
| License       | MIT
| Doc PR        | ~

This PR uses the new `ArgumentResolver` to inject a security user when the signature implies so. This is based on the [docs code example](https://github.com/symfony/symfony-docs/pull/6438#issuecomment-208319704) and [existing pr on the SFEB](sensiolabs/SensioFrameworkExtraBundle#327).

With the new example you can do the following:
```php
// when a User is mandatory, e.g. behind firewall
public function fooAction(UserInterface $user)

// when a User is optional, e.g. where it can be anonymous
public function barAction(UserInterface $user = null)
```
This deprecates the `Controller::getUser()` method.

I have added it on a priority of 40 so it falls just under the `RequestValueResolver`. This is because it's already used and the initial performance is less of an impact.

There was a comment asking if the `controller_argument.value_resolver` tag name wasn't too long. If decided this tag should change before 3.1 is released, I will update it in here.

*`RequestValueResolver` contains a small codestyle consistency fix.*

Commits
-------

d341889 Added a SecurityUserValueResolver for controllers
2016-07-01 10:03:07 +02:00
.composer Drop hirak/prestissimo 2016-05-12 07:44:15 -05:00
.github Merge branch '3.0' into 3.1 2016-06-30 12:07:58 +02:00
src/Symfony feature #18510 Added a SecurityUserValueResolver for controllers (iltar) 2016-07-01 10:03:07 +02:00
.editorconfig Add EditorConfig File 2012-06-16 14:08:15 +02:00
.gitignore Add appveyor.yml for C.I. on Windows 2015-08-25 23:41:37 +02:00
.php_cs fixed CS 2016-06-21 07:43:49 +02:00
.travis.yml Merge branch '3.1' 2016-06-30 11:40:30 +02:00
appveyor.yml [Cache] Optimize & wire PhpFilesAdapter 2016-05-31 18:28:43 +02:00
CHANGELOG-3.0.md Merge branch '2.8' into 3.0 2016-06-14 13:04:19 +02:00
CHANGELOG-3.1.md updated CHANGELOG for 3.1.1 2016-06-15 07:58:54 +02:00
composer.json feature #19153 [Validator] support egulias/email-validator 2.x (xabbuh) 2016-06-23 15:28:01 +02:00
CONTRIBUTING.md Update contributing docs 2016-02-24 15:36:06 +01:00
CONTRIBUTORS.md update CONTRIBUTORS for 2.7.14 2016-06-06 17:23:21 +02:00
LICENSE Update copyright year 2016-01-01 23:53:47 -03:00
phpunit [ci] Upgrade phpunit wrapper deps 2016-06-29 14:53:38 +02:00
phpunit.xml.dist use the clock mock for progress indicator tests 2016-03-17 10:19:04 +01:00
README.md Merge branch '2.8' 2015-06-04 22:30:47 +02:00
UPGRADE-3.0.md Merge branch '3.0' into 3.1 2016-06-21 07:59:09 +02:00
UPGRADE-3.1.md [FrameworkBundle] Update the UPGRADING files 2016-06-30 11:41:22 +02:00
UPGRADE-3.2.md Added a SecurityUserValueResolver for controllers 2016-07-01 08:00:40 +02:00
UPGRADE-4.0.md Added a SecurityUserValueResolver for controllers 2016-07-01 08:00:40 +02:00

README

What is Symfony?

Symfony is a PHP full-stack web framework. It is written with speed and flexibility in mind. It allows developers to build better and easy to maintain websites with PHP.

Symfony can be used to develop all kind of websites, from your personal blog to high traffic ones like Dailymotion or Yahoo! Answers.

Installation

The best way to install Symfony is to use the official Symfony Installer. It allows you to start a new project based on the version you want.

Documentation

The "Quick Tour" tutorial gives you a first feeling of the framework. If, like us, you think that Symfony can help speed up your development and take the quality of your work to the next level, read the official Symfony documentation.

Contributing

Symfony is an open source, community-driven project. If you'd like to contribute, please read the Contributing Code part of the documentation. If you're submitting a pull request, please follow the guidelines in the Submitting a Patch section and use Pull Request Template.

Running Symfony Tests

Information on how to run the Symfony test suite can be found in the Running Symfony Tests section.