Skip to content

Commit b90b51e

Browse files
committed
Merge branch '4.1'
* 4.1: Fixed a build issue supports() must return a boolean Clarifying that .env can be used on production fix the event subscriber code example
2 parents 29b7fda + 6cafe2e commit b90b51e

File tree

4 files changed

+27
-51
lines changed

4 files changed

+27
-51
lines changed

deployment.rst

+19-8
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,27 @@ B) Configure your Environment Variables
125125
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
126126

127127
Most Symfony applications read their configuration from environment variables.
128-
While developing locally, you'll usually store these in a ``.env`` file. But on
129-
production, instead of creating this file, you should set *real* environment variables.
128+
While developing locally, you'll usually store these in a ``.env`` file. On production,
129+
you have two options:
130130

131-
How you set environment variables, depends on your setup: they can be set at the
132-
command line, in your Nginx configuration, or via other methods provided by your
133-
hosting service.
131+
1. Create "real" environment variables. How you set environment variables, depends
132+
on your setup: they can be set at the command line, in your Nginx configuration,
133+
or via other methods provided by your hosting service.
134134

135-
At the very least you need to define the ``APP_ENV=prod`` environment variable
136-
to run the application in ``prod`` mode, but depending on your application you
137-
may need to define other env vars too.
135+
2. Or, create a ``.env`` file just like your local development (see note below)
136+
137+
There is no significant advantage to either of the two options: use whatever is
138+
most natural in your hosting environment.
139+
140+
.. note::
141+
142+
If you use the ``.env`` file on production, you may need to move your
143+
``symfony/dotenv`` dependency from ``require-dev`` to ``require`` in ``composer.json``:
144+
145+
.. code-block:: terminal
146+
147+
$ composer remove symfony/dotenv
148+
$ composer require symfony/dotenv
138149
139150
C) Install/Update your Vendors
140151
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

security/guard_authentication.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ are two possible fixes:
475475
public function supports(Request $request)
476476
{
477477
+ // if there is already an authenticated user (likely due to the session)
478-
+ // then return null and skip authentication: there is no need.
478+
+ // then return false and skip authentication: there is no need.
479479
+ if ($this->security->getUser()) {
480480
+ return false;
481481
+ }

serializer.rst

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ take a look at how this bundle works.
217217
:maxdepth: 1
218218

219219
serializer/custom_encoders
220+
serializer/custom_normalizer
220221

221222
.. _`APCu`: https://github.com/krakjoe/apcu
222223
.. _`ApiPlatform`: https://github.com/api-platform/core

session/locale_sticky_session.rst

+6-42
Original file line numberDiff line numberDiff line change
@@ -171,50 +171,14 @@ event::
171171
$this->session->set('_locale', $user->getLocale());
172172
}
173173
}
174-
}
175-
176-
Then register the listener:
177-
178-
.. configuration-block::
179-
180-
.. code-block:: yaml
181-
182-
# config/services.yaml
183-
services:
184-
App\EventListener\UserLocaleListener:
185-
tags:
186-
- { name: kernel.event_listener, event: security.interactive_login, method: onInteractiveLogin, priority: 15 }
187-
188-
.. code-block:: xml
189-
190-
<!-- config/services.xml -->
191-
<?xml version="1.0" encoding="UTF-8" ?>
192-
<container xmlns="http://symfony.com/schema/dic/services"
193-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
194-
xsi:schemaLocation="http://symfony.com/schema/dic/services
195-
http://symfony.com/schema/dic/services/services-1.0.xsd">
196-
197-
<services>
198-
<service id="App\EventListener\UserLocaleListener">
199-
<tag name="kernel.event_listener"
200-
event="security.interactive_login"
201-
method="onInteractiveLogin" priority=15 />
202-
</service>
203-
</services>
204-
</container>
205174

206-
.. code-block:: php
207-
208-
// config/services.php
209-
use AppBundle\EventListener\UserLocaleListener;
210-
use Symfony\Component\DependencyInjection\Reference;
211-
212-
$container
213-
->register(UserLocaleListener::class)
214-
->addTag(
215-
'kernel.event_listener',
216-
array('event' => 'security.interactive_login', 'method' => 'onInteractiveLogin', 'priority' => 15)
175+
public static function getSubscribedEvents()
176+
{
177+
return array(
178+
SecurityEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin',
217179
);
180+
}
181+
}
218182

219183
.. caution::
220184

0 commit comments

Comments
 (0)