Skip to content

Commit 380ae47

Browse files
committed
Merge branch '4.1'
* 4.1: Remove useless $request Improve the docs about custom form theme config Use callable classes for custom Monolog processors Mentioned the audit_trail workflow option Problem with transactions Update custom_password_authenticator.rst Updated one screencast URL for Symfony 4 Change dsn env var name Update dependency_injection.rst Update http_kernel_httpkernel_class.rst Remove example of register a service where its id match to its class
2 parents b202e64 + da8025c commit 380ae47

File tree

12 files changed

+37
-24
lines changed

12 files changed

+37
-24
lines changed

create_framework/dependency_injection.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Create a new file to host the dependency injection container configuration::
121121
->setArguments(array('UTF-8'))
122122
;
123123
$containerBuilder->register('listener.exception', HttpKernel\EventListener\ExceptionListener::class)
124-
->setArguments(array('Calendar\Controller\ErrorController::exceptionAction'))
124+
->setArguments(array('Calendar\Controller\ErrorController::exception'))
125125
;
126126
$containerBuilder->register('dispatcher', EventDispatcher\EventDispatcher::class)
127127
->addMethodCall('addSubscriber', array(new Reference('listener.router')))

create_framework/http_kernel_httpkernel_class.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ display. It can take any valid controller as an exception handler, so you can
8282
create an ErrorController class instead of using a Closure::
8383

8484
$listener = new HttpKernel\EventListener\ExceptionListener(
85-
'Calendar\Controller\ErrorController::exceptionAction'
85+
'Calendar\Controller\ErrorController::exception'
8686
);
8787
$dispatcher->addSubscriber($listener);
8888

doctrine.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ Take a look at the previous example in more detail:
402402
is thrown. See `Transactions and Concurrency`_.
403403

404404
Whether you're creating or updating objects, the workflow is always the same: Doctrine
405-
is smart enough to know if it should INSERT of UPDATE your entity.
405+
is smart enough to know if it should INSERT or UPDATE your entity.
406406

407407
Fetching Objects from the Database
408408
----------------------------------

doctrine/pdo_session_storage.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ To use it, first register a new handler service:
2929
# If you're using Doctrine & want to re-use that connection, then:
3030
# comment-out the above 2 lines and uncomment the line below
3131
# - !service { class: PDO, factory: 'database_connection:getWrappedConnection' }
32+
# If you get transaction issues (e.g. after login) uncomment the line below
33+
# - { lock_mode: 1 }
3234
3335
.. code-block:: xml
3436

form/form_themes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ file:
182182
# config/packages/twig.yaml
183183
twig:
184184
form_themes:
185+
- '...'
185186
- 'form/fields.html.twig'
186187
# ...
187188
@@ -197,6 +198,7 @@ file:
197198
http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd">
198199
199200
<twig:config>
201+
<twig:theme>...</twig:theme>
200202
<twig:theme>form/fields.html.twig</twig:theme>
201203
<!-- ... -->
202204
</twig:config>
@@ -207,11 +209,17 @@ file:
207209
// config/packages/twig.php
208210
$container->loadFromExtension('twig', array(
209211
'form_themes' => array(
212+
'...',
210213
'form/fields.html.twig',
211214
),
212215
// ...
213216
));
214217
218+
.. note::
219+
220+
Add your custom theme at the end of the ``form_themes`` list because each
221+
theme overrides all the previous themes.
222+
215223
Any blocks inside the ``fields.html.twig`` template are now used globally
216224
to define form output.
217225

logging/processors.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ using a processor::
3030
$this->session = $session;
3131
}
3232

33-
public function processRecord(array $record)
33+
public function __invoke(array $record)
3434
{
3535
if (!$this->session->isStarted()) {
3636
return $record;
@@ -62,7 +62,7 @@ information:
6262
6363
App\Logger\SessionRequestProcessor:
6464
tags:
65-
- { name: monolog.processor, method: processRecord }
65+
- { name: monolog.processor }
6666
6767
.. code-block:: xml
6868
@@ -84,7 +84,7 @@ information:
8484
</service>
8585
8686
<service id="App\Logger\SessionRequestProcessor">
87-
<tag name="monolog.processor" method="processRecord" />
87+
<tag name="monolog.processor" />
8888
</service>
8989
</services>
9090
</container>
@@ -195,7 +195,7 @@ the ``monolog.processor`` tag:
195195
services:
196196
App\Logger\SessionRequestProcessor:
197197
tags:
198-
- { name: monolog.processor, method: processRecord, handler: main }
198+
- { name: monolog.processor, handler: main }
199199
200200
.. code-block:: xml
201201
@@ -211,7 +211,7 @@ the ``monolog.processor`` tag:
211211
212212
<services>
213213
<service id="App\Logger\SessionRequestProcessor">
214-
<tag name="monolog.processor" method="processRecord" handler="main" />
214+
<tag name="monolog.processor" handler="main" />
215215
</service>
216216
</services>
217217
</container>
@@ -223,7 +223,7 @@ the ``monolog.processor`` tag:
223223
// ...
224224
$container
225225
->register(SessionRequestProcessor::class)
226-
->addTag('monolog.processor', array('method' => 'processRecord', 'handler' => 'main'));
226+
->addTag('monolog.processor', array('handler' => 'main'));
227227
228228
Registering Processors per Channel
229229
----------------------------------
@@ -239,7 +239,7 @@ the ``monolog.processor`` tag:
239239
services:
240240
App\Logger\SessionRequestProcessor:
241241
tags:
242-
- { name: monolog.processor, method: processRecord, channel: main }
242+
- { name: monolog.processor, channel: main }
243243
244244
.. code-block:: xml
245245
@@ -255,7 +255,7 @@ the ``monolog.processor`` tag:
255255
256256
<services>
257257
<service id="App\Logger\SessionRequestProcessor">
258-
<tag name="monolog.processor" method="processRecord" channel="main" />
258+
<tag name="monolog.processor" channel="main" />
259259
</service>
260260
</services>
261261
</container>
@@ -267,4 +267,4 @@ the ``monolog.processor`` tag:
267267
// ...
268268
$container
269269
->register(SessionRequestProcessor::class)
270-
->addTag('monolog.processor', array('method' => 'processRecord', 'channel' => 'main'));
270+
->addTag('monolog.processor', array('channel' => 'main'));

messenger.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ the messenger component, the following configuration should have been created:
123123
framework:
124124
messenger:
125125
transports:
126-
amqp: "%env(MESSENGER_DSN)%"
126+
amqp: "%env(MESSENGER_TRANSPORT_DSN)%"
127127
128128
.. code-block:: xml
129129
@@ -139,7 +139,7 @@ the messenger component, the following configuration should have been created:
139139
140140
<framework:config>
141141
<framework:messenger>
142-
<framework:transport name="amqp" dsn="%env(MESSENGER_DSN)%" />
142+
<framework:transport name="amqp" dsn="%env(MESSENGER_TRANSPORT_DSN)%" />
143143
</framework:messenger>
144144
</framework:config>
145145
</container>
@@ -150,7 +150,7 @@ the messenger component, the following configuration should have been created:
150150
$container->loadFromExtension('framework', array(
151151
'messenger' => array(
152152
'transports' => array(
153-
'amqp' => '%env(MESSENGER_DSN)%',
153+
'amqp' => '%env(MESSENGER_TRANSPORT_DSN)%',
154154
),
155155
),
156156
));

security.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,4 +1348,4 @@ Other Security Related Topics
13481348
.. _`frameworkextrabundle documentation`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/index.html
13491349
.. _`HWIOAuthBundle`: https://github.com/hwi/HWIOAuthBundle
13501350
.. _`Symfony ACL bundle`: https://github.com/symfony/acl-bundle
1351-
.. _`Symfony Security screencast series`: https://knpuniversity.com/screencast/symfony-security
1351+
.. _`Symfony Security screencast series`: https://knpuniversity.com/screencast/symfony4-security

security/custom_password_authenticator.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ the user::
6363
if ('' === ($givenPassword = $token->getCredentials())) {
6464
throw new BadCredentialsException('The given password cannot be empty.');
6565
}
66-
if (!$this->encoderFactory->getEncoder($user)->isPasswordValid($user->getPassword(), $givenPassword, $user->getSalt())) {
66+
if (!$this->encoder->isPasswordValid($user->getPassword(), $givenPassword, $user->getSalt())) {
6767
throw new BadCredentialsException('The given password is invalid.');
6868
}
6969
}

security/form_login_setup.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,14 @@ configuration (``login``):
9191
// src/Controller/SecurityController.php
9292
9393
// ...
94-
use Symfony\Component\HttpFoundation\Request;
9594
use Symfony\Component\Routing\Annotation\Route;
9695
9796
class SecurityController extends Controller
9897
{
9998
/**
10099
* @Route("/login", name="login")
101100
*/
102-
public function login(Request $request)
101+
public function login()
103102
{
104103
}
105104
}
@@ -144,7 +143,7 @@ Great! Next, add the logic to ``login()`` that displays the login form::
144143
// src/Controller/SecurityController.php
145144
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
146145

147-
public function login(Request $request, AuthenticationUtils $authenticationUtils)
146+
public function login(AuthenticationUtils $authenticationUtils)
148147
{
149148
// get the login error if there is one
150149
$error = $authenticationUtils->getLastAuthenticationError();

service_container/definitions.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ There are some helpful methods for working with the service definitions::
3838
// shortcut for the previous method
3939
$container->register('app.number_generator', \App\NumberGenerator::class);
4040

41-
// or create a service whose id matches its class
42-
$container->register(\App\NumberGenerator::class);
43-
4441
Working with a Definition
4542
-------------------------
4643

workflow/usage.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ like this:
4040
workflows:
4141
blog_publishing:
4242
type: 'workflow' # or 'state_machine'
43+
audit_trail: 'enabled'
4344
marking_store:
4445
type: 'multiple_state' # or 'single_state'
4546
arguments:
@@ -75,7 +76,7 @@ like this:
7576
>
7677
7778
<framework:config>
78-
<framework:workflow name="blog_publishing" type="workflow">
79+
<framework:workflow name="blog_publishing" type="workflow" audit_trail="enabled">
7980
<framework:marking-store type="single_state">
8081
<framework:argument>currentPlace</framework:argument>
8182
</framework:marking-store>
@@ -119,6 +120,7 @@ like this:
119120
'workflows' => array(
120121
'blog_publishing' => array(
121122
'type' => 'workflow', // or 'state_machine'
123+
'audit_trail' => 'enabled',
122124
'marking_store' => array(
123125
'type' => 'multiple_state', // or 'single_state'
124126
'arguments' => array('currentPlace')
@@ -170,6 +172,11 @@ like this:
170172
value ``marking``) attributes of the ``marking_store`` option are optional.
171173
If omitted, their default values will be used.
172174

175+
.. tip::
176+
177+
Setting the ``audit_trail`` option to ``enabled`` makes the application
178+
generate detailed log messages for the workflow activity.
179+
173180
Using a Workflow
174181
----------------
175182

0 commit comments

Comments
 (0)