Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit81637c5

Browse files
committed
Merge branch '5.1' into 5.2
* 5.1: Enhancement: Streamline workflow GitHub Actions: use docker container for CI build Bus restricting with Interfaces Security: add example code which Maker Bundle generated [#14550] Reduce nr of lines used for exception Section method only in ConsoleOutputInterface
2 parents55b9b17 +d71a07e commit81637c5

File tree

5 files changed

+154
-87
lines changed

5 files changed

+154
-87
lines changed

‎.github/workflows/ci.yaml

Lines changed: 43 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name:CI
2+
13
on:
24
push:
35
branches-ignore:
@@ -6,83 +8,73 @@ on:
68
branches-ignore:
79
-'github-comments'
810

9-
name:CI
10-
1111
jobs:
12-
build:
13-
name:Build
12+
sphinx-build:
13+
name:Build (Sphinx)
1414

1515
runs-on:ubuntu-latest
1616

17+
container:python:3.7-alpine
18+
1719
steps:
1820
-name:"Checkout"
1921
uses:actions/checkout@v2
2022

21-
-name:"Set up Python 3.7"
22-
uses:actions/setup-python@v1
23-
with:
24-
python-version:'3.7'# Semantic version range syntax or exact version of a Python version
25-
2623
-name:"Display Python version"
2724
run:python -c "import sys; print(sys.version)"
2825

29-
-name:"Install Sphinx dependencies"
30-
run:sudo apt-getinstallpython-dev build-essential
26+
-name:"Install Sphinx"
27+
run:pipinstall--user sphinx
3128

32-
-name:"Cache pip"
33-
uses:actions/cache@v2
34-
with:
35-
path:~/.cache/pip
36-
key:${{ runner.os }}-pip-${{ hashFiles('_build/.requirements.txt') }}
37-
restore-keys:|
38-
${{ runner.os }}-pip-
29+
-name:"Install dependencies"
30+
run:apk add --no-cache git make
3931

40-
-name:"InstallSphinx + requirements via pip"
32+
-name:"Installcustom requirements via pip"
4133
run:pip install -r _build/.requirements.txt
4234

4335
-name:"Build documentation"
4436
run:make -C _build SPHINXOPTS="-nqW -j auto" html
4537

46-
build-php:
47-
name:Symfony docbuilder
38+
symfony-docs-builder-build:
39+
name:Build (symfony/docs-builder)
4840

4941
runs-on:ubuntu-latest
5042

5143
continue-on-error:true
5244

5345
steps:
54-
-name:"Checkout"
55-
uses:actions/checkout@v2
56-
57-
-name:"Set-up PHP"
58-
uses:shivammathur/setup-php@v2
59-
with:
60-
php-version:7.2
61-
coverage:none
62-
tools:"composer:v2"
63-
64-
-name:Get composer cache directory
65-
id:composercache
66-
working-directory:_build
67-
run:echo "::set-output name=dir::$(composer config cache-files-dir)"
68-
69-
-name:Cache dependencies
70-
uses:actions/cache@v2
71-
with:
72-
path:${{ steps.composercache.outputs.dir }}
73-
key:${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
74-
restore-keys:${{ runner.os }}-composer-
75-
76-
-name:"Install dependencies"
77-
working-directory:_build
78-
run:composer install --prefer-dist --no-progress
79-
80-
-name:"Build the docs"
81-
working-directory:_build
82-
run:php build.php -vvv
46+
-name:"Checkout"
47+
uses:actions/checkout@v2
48+
49+
-name:"Set-up PHP"
50+
uses:shivammathur/setup-php@v2
51+
with:
52+
php-version:7.2
53+
coverage:none
54+
tools:"composer:v2"
55+
56+
-name:Get composer cache directory
57+
id:composercache
58+
working-directory:_build
59+
run:echo "::set-output name=dir::$(composer config cache-files-dir)"
60+
61+
-name:Cache dependencies
62+
uses:actions/cache@v2
63+
with:
64+
path:${{ steps.composercache.outputs.dir }}
65+
key:${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
66+
restore-keys:${{ runner.os }}-composer-
67+
68+
-name:"Install dependencies"
69+
working-directory:_build
70+
run:composer install --prefer-dist --no-progress
71+
72+
-name:"Build the docs"
73+
working-directory:_build
74+
run:php build.php -vvv
8375

8476
doctor-rst:
85-
name:DOCtor-RST
77+
name:Lint (DOCtor-RST)
8678

8779
runs-on:ubuntu-latest
8880

‎console.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,24 @@ called "output sections". Create one or more of these sections when you need to
187187
clear and overwrite the output information.
188188

189189
Sections are created with the
190-
:method:`Symfony\\Component\\Console\\Output\\ConsoleOutput::section` method,
191-
which returns an instance of
190+
:method:`ConsoleOutput::section() <Symfony\\Component\\Console\\Output\\ConsoleOutput::section>`
191+
method,which returns an instance of
192192
:class:`Symfony\\Component\\Console\\Output\\ConsoleSectionOutput`::
193193

194+
// ...
195+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
196+
194197
class MyCommand extends Command
195198
{
196199
protected function execute(InputInterface $input, OutputInterface $output)
197200
{
201+
if (!$output instanceof ConsoleOutputInterface) {
202+
throw new \LogicException('This command accepts only an instance of "ConsoleOutputInterface".');
203+
}
204+
198205
$section1 = $output->section();
199206
$section2 = $output->section();
207+
200208
$section1->writeln('Hello');
201209
$section2->writeln('World!');
202210
// Output displays "Hello\nWorld!\n"

‎messenger/multiple_buses.rst

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -150,30 +150,30 @@ you can restrict each handler to a specific bus using the ``messenger.message_ha
150150
This way, the ``App\MessageHandler\SomeCommandHandler`` handler will only be
151151
known by the ``command.bus`` bus.
152152

153-
You can also automatically add this tag to a number of classes byfollowing
154-
a naming convention and registering all ofthehandler services by name with
155-
thecorrect tag:
153+
You can also automatically add this tag to a number of classes byusing
154+
the:ref:`_instanceof service configuration<di-instanceof>`. Using this,
155+
you can determinethemessage bus based on an implemented interface:
156156

157157
..configuration-block::
158158

159159
..code-block::yaml
160160
161161
# config/services.yaml
162+
services:
163+
# ...
164+
165+
_instanceof:
166+
# all services implementing the CommandHandlerInterface
167+
# will be registered on the command.bus bus
168+
App\MessageHandler\CommandHandlerInterface:
169+
tags:
170+
-{ name: messenger.message_handler, bus: command.bus }
162171
163-
# put this after the "App\" line that registers all your services
164-
command_handlers:
165-
namespace:App\MessageHandler\
166-
resource:'%kernel.project_dir%/src/MessageHandler/*CommandHandler.php'
167-
autoconfigure:false
168-
tags:
169-
-{ name: messenger.message_handler, bus: command.bus }
170-
171-
query_handlers:
172-
namespace:App\MessageHandler\
173-
resource:'%kernel.project_dir%/src/MessageHandler/*QueryHandler.php'
174-
autoconfigure:false
175-
tags:
176-
-{ name: messenger.message_handler, bus: query.bus }
172+
# while those implementing QueryHandlerInterface will be
173+
# registered on the query.bus bus
174+
App\MessageHandler\QueryHandlerInterface:
175+
tags:
176+
-{ name: messenger.message_handler, bus: query.bus }
177177
178178
..code-block::xml
179179
@@ -185,32 +185,45 @@ the correct tag:
185185
https://symfony.com/schema/dic/services/services-1.0.xsd">
186186
187187
<services>
188-
<!-- command handlers-->
189-
<prototypenamespace="App\MessageHandler\"resource="%kernel.project_dir%/src/MessageHandler/*CommandHandler.php"autoconfigure="false">
188+
<!-- ...-->
189+
190+
<!-- all services implementing the CommandHandlerInterface
191+
will be registered on the command.bus bus-->
192+
<instanceofid="App\MessageHandler\CommandHandlerInterface">
190193
<tagname="messenger.message_handler"bus="command.bus"/>
191-
</prototype>
192-
<!-- query handlers-->
193-
<prototypenamespace="App\MessageHandler\"resource="%kernel.project_dir%/src/MessageHandler/*QueryHandler.php"autoconfigure="false">
194+
</instanceof>
195+
196+
<!-- while those implementing QueryHandlerInterface will be
197+
registered on the query.bus bus-->
198+
<instanceofid="App\MessageHandler\QueryHandlerInterface">
194199
<tagname="messenger.message_handler"bus="query.bus"/>
195-
</prototype>
200+
</instanceof>
196201
</services>
197202
</container>
198203
199204
..code-block::php
200205
201206
// config/services.php
207+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
202208
203-
// Command handlers
204-
$container->services()
205-
->load('App\MessageHandler\\', '%kernel.project_dir%/src/MessageHandler/*CommandHandler.php')
206-
->autoconfigure(false)
207-
->tag('messenger.message_handler', ['bus' => 'command.bus']);
209+
use App\MessageHandler\CommandHandlerInterface;
210+
use App\MessageHandler\QueryHandlerInterface;
208211
209-
// Query handlers
210-
$container->services()
211-
->load('App\MessageHandler\\', '%kernel.project_dir%/src/MessageHandler/*QueryHandler.php')
212-
->autoconfigure(false)
213-
->tag('messenger.message_handler', ['bus' => 'query.bus']);
212+
return function(ContainerConfigurator $configurator) {
213+
$services = $configurator->services();
214+
215+
// ...
216+
217+
// all services implementing the CommandHandlerInterface
218+
// will be registered on the command.bus bus
219+
$services->instanceof(CommandHandlerInterface::class)
220+
->tag('messenger.message_handler', ['bus' => 'command.bus']);
221+
222+
// while those implementing QueryHandlerInterface will be
223+
// registered on the query.bus bus
224+
$services->instanceof(QueryHandlerInterface::class)
225+
->tag('messenger.message_handler', ['bus' => 'query.bus']);
226+
};
214227
215228
Debugging the Buses
216229
-------------------

‎security.rst

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,59 @@ optional features, like :doc:`remember me </security/remember_me>` and
139139
:doc:`impersonation</security/impersonating_user>`.
140140

141141
Fortunately, the ``make:user`` command already configured one for you in your
142-
``security.yaml`` file under the ``providers`` key.
142+
``security.yaml`` file under the ``providers`` key:
143+
144+
..configuration-block::
145+
146+
..code-block::yaml
147+
148+
# config/packages/security.yaml
149+
security:
150+
# ...
151+
152+
providers:
153+
# used to reload user from session & other features (e.g. switch_user)
154+
app_user_provider:
155+
entity:
156+
class:App\Entity\User
157+
property:email
158+
159+
..code-block::xml
160+
161+
<!-- config/packages/security.xml-->
162+
<?xml version="1.0" encoding="UTF-8"?>
163+
<srv:containerxmlns="http://symfony.com/schema/dic/security"
164+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
165+
xmlns:srv="http://symfony.com/schema/dic/services"
166+
xsi:schemaLocation="http://symfony.com/schema/dic/services
167+
https://symfony.com/schema/dic/services/services-1.0.xsd">
168+
169+
<config>
170+
<!-- used to reload user from session & other features (e.g. switch-user)-->
171+
<providername="app_user_provider">
172+
<entityclass="App\Entity\User"property="email"/>
173+
</provider>
174+
</config>
175+
</srv:container>
176+
177+
..code-block::php
178+
179+
// config/packages/security.php
180+
use App\Entity\User;
181+
182+
$container->loadFromExtension('security', [
183+
// ...
184+
185+
'providers' => [
186+
// used to reload user from session & other features (e.g. switch_user)
187+
'app_user_provider' => [
188+
'entity' => [
189+
'class' => User::class,
190+
'property' => 'email',
191+
],
192+
],
193+
],
194+
]);
143195
144196
If your ``User`` class is an entity, you don't need to do anything else. But if
145197
your class is *not* an entity, then ``make:user`` will also have generated a

‎service_container/tags.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ and many tags require additional arguments (beyond the ``name`` parameter).
6060
**For most users, this is all you need to know**. If you want to go further and
6161
learn how to create your own custom tags, keep reading.
6262

63+
.. _di-instanceof:
64+
6365
Autoconfiguring Tags
6466
--------------------
6567

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp