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

Commit4765b7d

Browse files
committed
Merge branch '3.4' into 4.1
* 3.4: Updated the command to run the Docker image [Doctrine Bridge] document priority for doctrine.event_listener tag Improved the docs of the instanceof config Add details on how the ClockMock::register works Add Dockerfile Fix function name in expression
2 parents4a020ab +6f6b216 commit4765b7d

File tree

6 files changed

+181
-15
lines changed

6 files changed

+181
-15
lines changed

‎Dockerfile‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:2-stretch as builder
2+
3+
WORKDIR /www
4+
5+
COPY ./_build/.requirements.txt _build/
6+
7+
RUN pip install pip==9.0.1 wheel==0.29.0 \
8+
&& pip install -r _build/.requirements.txt
9+
10+
COPY . /www
11+
12+
RUN make -C _build html
13+
14+
FROM nginx:latest
15+
16+
COPY --from=builder /www/_build/html /usr/share/nginx/html

‎README.markdown‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,17 @@ Platform.sh
1919
-----------
2020

2121
Pull requests are automatically built by[Platform.sh](https://platform.sh).
22+
23+
Docker
24+
------
25+
26+
You can build the doc locally with these commands:
27+
28+
```bash
29+
# build the image...
30+
$ docker build. -t symfony-docs
31+
32+
# ...and serve it locally on http//:127.0.0.1:8080
33+
# (if it's already in use, change the '8080' port by any other port)
34+
$ docker run --rm -p 8080:80 symfony-docs
35+
```

‎components/phpunit_bridge.rst‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,48 @@ test::
352352

353353
And that's all!
354354

355+
..caution::
356+
357+
Time-based function mocking follows the `PHP namespace resolutions rules`_
358+
so "fully qualified function calls" (e.g ``\time()``) cannot be mocked.
359+
360+
The ``@group time-sensitive`` annotation is equivalent to calling
361+
``ClockMock::register(MyTest::class)``. If you want to mock a function used in a
362+
different class, do it explicitly using ``ClockMock::register(MyClass::class)``::
363+
364+
// the class that uses the time() function to be mocked
365+
namespace App;
366+
367+
class MyClass
368+
{
369+
public function getTimeInHours()
370+
{
371+
return time() / 3600;
372+
}
373+
}
374+
375+
// the test that mocks the external time() function explicitly
376+
namespace App\Tests;
377+
378+
use App\MyClass;
379+
use PHPUnit\Framework\TestCase;
380+
381+
/**
382+
* @group time-sensitive
383+
*/
384+
class MyTest extends TestCase
385+
{
386+
public function testGetTimeInHours()
387+
{
388+
ClockMock::register(MyClass::class);
389+
390+
$my = new MyClass();
391+
$result = $my->getTimeInHours();
392+
393+
$this->assertEquals(time() / 3600, $result);
394+
}
395+
}
396+
355397
..tip::
356398

357399
An added bonus of using the ``ClockMock`` class is that time passes
@@ -633,3 +675,4 @@ not find the SUT:
633675
.. _`Travis CI`:https://travis-ci.org/
634676
.. _`test listener`:https://phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.test-listeners
635677
.. _`@covers`:https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.covers
678+
.. _`PHP namespace resolutions rules`:https://php.net/manual/en/language.namespaces.rules.php

‎doctrine/event_listeners_subscribers.rst‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,57 @@ to the tag like so:
241241

242242
.. _`The Event System`:http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html
243243
.. _`the Doctrine Documentation`:https://symfony.com/doc/current/bundles/DoctrineBundle/entity-listeners.html
244+
245+
Priorities for Event Listeners
246+
------------------------------
247+
248+
In case you have multiple listeners for the same event you can control the order
249+
in which they are invoked using the ``priority`` attribute on the tag.
250+
Listeners with a higher priority are invoked first.
251+
252+
..configuration-block::
253+
254+
..code-block::yaml
255+
256+
# config/services.yaml
257+
services:
258+
App\EventListener\MyHighPriorityListener:
259+
tags:
260+
-{ name: doctrine.event_listener, event: postPersist, priority: 10 }
261+
262+
App\EventListener\MyLowPriorityListener:
263+
tags:
264+
-{ name: doctrine.event_listener, event: postPersist, priority: 1 }
265+
266+
..code-block::xml
267+
268+
<!-- config/services.xml-->
269+
<?xml version="1.0" ?>
270+
<containerxmlns="http://symfony.com/schema/dic/services"
271+
xmlns:doctrine="http://symfony.com/schema/dic/doctrine">
272+
273+
<services>
274+
<serviceid="App\EventListener\MyHighPriorityListener"autowire="true">
275+
<tagname="doctrine.event_listener"event="postPersist"priority="10" />
276+
</service>
277+
<serviceid="App\EventListener\MyLowPriorityListener"autowire="true">
278+
<tagname="doctrine.event_listener"event="postPersist"priority="1" />
279+
</service>
280+
</services>
281+
</container>
282+
283+
..code-block::php
284+
285+
// config/services.php
286+
use AppBundle\EventListener\MyHighPriorityListener;
287+
use AppBundle\EventListener\MyLowPriorityListener;
288+
289+
$container
290+
->autowire(MyHighPriorityListener::class)
291+
->addTag('doctrine.event_listener', array('event' => 'postPersist', 'priority' => 10))
292+
;
293+
294+
$container
295+
->autowire(MyLowPriorityListener::class)
296+
->addTag('doctrine.event_listener', array('event' => 'postPersist', 'priority' => 1))
297+
;

‎security/expressions.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Additionally, you have access to a number of functions inside the expression:
6767

6868
..sidebar::``is_remember_me`` is different than checking ``IS_AUTHENTICATED_REMEMBERED``
6969

70-
The ``is_remember_me()`` and ``is_authenticated_fully()`` functions are *similar*
70+
The ``is_remember_me()`` and ``is_fully_authenticated()`` functions are *similar*
7171
to using ``IS_AUTHENTICATED_REMEMBERED`` and ``IS_AUTHENTICATED_FULLY``
7272
with the ``isGranted()`` function - but they are **not** the same. The
7373
following controller snippet shows the difference::

‎service_container/tags.rst‎

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,63 @@ automatically applied for you. That's true for the ``twig.extension`` tag: the
6363
container sees that your class extends ``AbstractExtension`` (or more accurately,
6464
that it implements ``ExtensionInterface``) and adds the tag for you.
6565

66-
..tip::
66+
If you want to apply tags automatically for your own services, use the
67+
``_instanceof`` option::
6768

68-
To apply a tag to all your autoconfigured services extending a class or implementing an
69-
interface, call the:method:`Symfony\\Component\\DependencyInjection\\ContainerBuilder::registerForAutoconfiguration`
70-
method in an:doc:`extension</bundles/extension>` or from your kernel::
69+
..configuration-block::
7170

72-
// src/Kernel.php
73-
class Kernel extends Kernel
74-
{
75-
// ...
71+
..code-block::yaml
7672
77-
protected function build(ContainerBuilder $container)
78-
{
79-
$container->registerForAutoconfiguration(CustomInterface::class)
80-
->addTag('app.custom_tag')
81-
;
82-
}
73+
# config/services.yaml
74+
services:
75+
# this config only applies to the services created by this file
76+
_instanceof:
77+
# services whose classes are instances of CustomInterface will be tagged automatically
78+
App\Security\CustomInterface:
79+
tags:['app.custom_tag']
80+
# ...
81+
82+
..code-block::xml
83+
84+
<!-- config/services.xml-->
85+
<?xml version="1.0" encoding="utf-8"?>
86+
<containerxmlns="http://symfony.com/schema/dic/services"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
87+
<services>
88+
<!-- this config only applies to the services created by this file-->
89+
<instanceofid="App\Security\CustomInterface"autowire="true">
90+
<!-- services whose classes are instances of CustomInterface will be tagged automatically-->
91+
<tagname="app.custom_tag" />
92+
</instanceof>
93+
</services>
94+
</container>
95+
96+
..code-block::php
97+
98+
// config/services.php
99+
use App\Security\CustomInterface;
100+
// ...
101+
102+
// services whose classes are instances of CustomInterface will be tagged automatically
103+
$container->registerForAutoconfiguration(CustomInterface::class)
104+
->addTag('app.custom_tag')
105+
->setAutowired(true);
106+
107+
For more advanced needs, you can define the automatic tags using the
108+
:method:`Symfony\\Component\\DependencyInjection\\ContainerBuilder::registerForAutoconfiguration`
109+
method in an:doc:`extension</bundles/extension>` or from your kernel::
110+
111+
// src/Kernel.php
112+
class Kernel extends BaseKernel
113+
{
114+
// ...
115+
116+
protected function build(ContainerBuilder $container)
117+
{
118+
$container->registerForAutoconfiguration(CustomInterface::class)
119+
->addTag('app.custom_tag')
120+
;
83121
}
122+
}
84123

85124
Creating custom Tags
86125
--------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp