Skip to content

Commit 9916abf

Browse files
committed
Merge branch '2.7' into 2.8
Conflicts: reference/forms/types/entity.rst
2 parents f3d4687 + 2038123 commit 9916abf

File tree

10 files changed

+84
-36
lines changed

10 files changed

+84
-36
lines changed

components/console/introduction.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Coloring the Output
143143
By default, the Windows command console doesn't support output coloring. The
144144
Console component disables output coloring for Windows systems, but if your
145145
commands invoke other scripts which emit color sequences, they will be
146-
wrongly displayed as raw escape characters. Install the `ConEmu`_, `ANSICON`_
146+
wrongly displayed as raw escape characters. Install the `Cmder`_, `ConEmu`_, `ANSICON`_
147147
or `Mintty`_ (used by default in GitBash and Cygwin) free applications
148148
to add coloring support to your Windows command console.
149149

@@ -581,6 +581,7 @@ Learn More!
581581
* :doc:`/components/console/console_arguments`
582582

583583
.. _Packagist: https://packagist.org/packages/symfony/console
584+
.. _Cmder: http://cmder.net/
584585
.. _ConEmu: https://conemu.github.io/
585586
.. _ANSICON: https://github.com/adoxa/ansicon/releases
586587
.. _Mintty: https://mintty.github.io/

components/dependency_injection/lazy_services.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ your lazy loaded services are working.
100100

101101
.. note::
102102

103-
If you don't install the `ProxyManager bridge`_, the container will
104-
just skip over the ``lazy`` flag and simply instantiate the service
105-
as it would normally do.
103+
If you don't install the `ProxyManager bridge`_ and the
104+
`ocramius/proxy-manager`_, the container will just skip over the ``lazy``
105+
flag and simply instantiate the service as it would normally do.
106106

107107
The proxy gets initialized and the actual service is instantiated as soon
108108
as you interact in any way with this object.
@@ -117,3 +117,4 @@ in the `documentation of ProxyManager`_.
117117
.. _`ProxyManager bridge`: https://github.com/symfony/symfony/tree/master/src/Symfony/Bridge/ProxyManager
118118
.. _`proxy`: https://en.wikipedia.org/wiki/Proxy_pattern
119119
.. _`documentation of ProxyManager`: https://github.com/Ocramius/ProxyManager/blob/master/docs/lazy-loading-value-holder.md
120+
.. _`ocramius/proxy-manager`: https://github.com/Ocramius/ProxyManager

contributing/code/tests.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ what's going on and if the tests are broken because of the new code.
5151
5252
.. tip::
5353

54-
On Windows, install the `ConEmu`_, `ANSICON`_ or `Mintty`_ free applications
54+
On Windows, install the `Cmder`_, `ConEmu`_, `ANSICON`_ or `Mintty`_ free applications
5555
to see colored test results.
5656

57+
.. _Cmder: http://cmder.net/
5758
.. _ConEmu: https://code.google.com/p/conemu-maximus5/
5859
.. _ANSICON: https://github.com/adoxa/ansicon/releases
5960
.. _Mintty: https://mintty.github.io/

cookbook/bundles/extension.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,39 @@ Using Configuration to Change the Services
125125
The Extension is also the class that handles the configuration for that
126126
particular bundle (e.g. the configuration in ``app/config/config.yml``). To
127127
read more about it, see the ":doc:`/cookbook/bundles/configuration`" article.
128+
129+
Adding Classes to Compile
130+
-------------------------
131+
132+
Symfony creates a big ``classes.php`` file in the cache directory to aggregate
133+
the contents of the PHP classes that are used in every request. This reduces the
134+
I/O operations and increases the application performance.
135+
136+
Your bundles can also add their own classes into this file thanks to the
137+
``addClassesToCompile()`` method. Define the classes to compile as an array of
138+
their fully qualified class names::
139+
140+
// ...
141+
public function load(array $configs, ContainerBuilder $container)
142+
{
143+
// ...
144+
145+
$this->addClassesToCompile(array(
146+
'AppBundle\\Manager\\UserManager',
147+
'AppBundle\\Utils\\Slugger',
148+
// ...
149+
));
150+
}
151+
152+
.. note::
153+
154+
If some class extends from other classes, all its parents are automatically
155+
included in the list of classes to compile.
156+
157+
Beware that this technique **can't be used in some cases**:
158+
159+
* When classes contain annotations, such as controllers with ``@Route``
160+
annotations and entities with ``@ORM`` or ``@Assert`` annotations, because
161+
the file location retrieved from PHP reflection changes;
162+
* When classes use the ``__DIR__`` and ``__FILE__`` constants, because their
163+
values will change when loading these classes from the ``classes.php`` file.

cookbook/console/logging.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ First configure a listener for console exception events in the service container
8484
8585
# app/config/services.yml
8686
services:
87-
kernel.listener.command_dispatch:
87+
app.listener.command_exception:
8888
class: AppBundle\EventListener\ConsoleExceptionListener
8989
arguments: ['@logger']
9090
tags:
@@ -99,7 +99,7 @@ First configure a listener for console exception events in the service container
9999
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
100100
101101
<services>
102-
<service id="kernel.listener.command_dispatch" class="AppBundle\EventListener\ConsoleExceptionListener">
102+
<service id="app.listener.command_exception" class="AppBundle\EventListener\ConsoleExceptionListener">
103103
<argument type="service" id="logger"/>
104104
<tag name="kernel.event_listener" event="console.exception" />
105105
</service>
@@ -121,7 +121,7 @@ First configure a listener for console exception events in the service container
121121
array('event' => 'console.exception')
122122
);
123123
$container->setDefinition(
124-
'kernel.listener.command_dispatch',
124+
'app.listener.command_exception',
125125
$definitionConsoleExceptionListener
126126
);
127127
@@ -181,7 +181,7 @@ First configure a listener for console terminate events in the service container
181181
182182
# app/config/services.yml
183183
services:
184-
kernel.listener.command_dispatch:
184+
app.listener.command_error:
185185
class: AppBundle\EventListener\ErrorLoggerListener
186186
arguments: ['@logger']
187187
tags:
@@ -196,7 +196,7 @@ First configure a listener for console terminate events in the service container
196196
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
197197
198198
<services>
199-
<service id="kernel.listener.command_dispatch" class="AppBundle\EventListener\ErrorLoggerListener">
199+
<service id="app.listener.command_error" class="AppBundle\EventListener\ErrorLoggerListener">
200200
<argument type="service" id="logger"/>
201201
<tag name="kernel.event_listener" event="console.terminate" />
202202
</service>
@@ -218,7 +218,7 @@ First configure a listener for console terminate events in the service container
218218
array('event' => 'console.terminate')
219219
);
220220
$container->setDefinition(
221-
'kernel.listener.command_dispatch',
221+
'app.listener.command_error',
222222
$definitionErrorLoggerListener
223223
);
224224

cookbook/console/style.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ Result Methods
303303

304304
:method:`Symfony\\Component\\Console\\Style\\SymfonyStyle::warning`
305305
It displays the given string or array of strings highlighted as a warning
306-
message (with a read background and the ``[WARNING]`` label). It's meant to be
306+
message (with a red background and the ``[WARNING]`` label). It's meant to be
307307
used once to display the final result of executing the given command, but you
308308
can use it repeatedly during the execution of the command::
309309

@@ -320,7 +320,7 @@ Result Methods
320320

321321
:method:`Symfony\\Component\\Console\\Style\\SymfonyStyle::error`
322322
It displays the given string or array of strings highlighted as an error
323-
message (with a read background and the ``[ERROR]`` label). It's meant to be
323+
message (with a red background and the ``[ERROR]`` label). It's meant to be
324324
used once to display the final result of executing the given command, but you
325325
can use it repeatedly during the execution of the command::
326326

cookbook/frontend/bower.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ it's installed correctly.
2525
.. tip::
2626

2727
If you don't want to have NodeJS on your computer, you can also use
28-
BowerPHP_ (an unofficial PHP port of Bower). Beware that this is still in
29-
an alpha state. If you're using BowerPHP, use ``bowerphp`` instead of
28+
BowerPHP_ (an unofficial PHP port of Bower). Beware that this is currently
29+
in beta status. If you're using BowerPHP, use ``bowerphp`` instead of
3030
``bower`` in the examples.
3131

3232
Configuring Bower in your Project

cookbook/profiler/profiling_data.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ The ``profiler`` service also provides the
3434
look for tokens based on some criteria::
3535

3636
// get the latest 10 tokens
37-
$tokens = $container->get('profiler')->find('', '', 10, '', '');
37+
$tokens = $container->get('profiler')->find('', '', 10, '', '', '');
3838

3939
// get the latest 10 tokens for all URL containing /admin/
40-
$tokens = $container->get('profiler')->find('', '/admin/', 10, '', '');
40+
$tokens = $container->get('profiler')->find('', '/admin/', 10, '', '', '');
4141

42-
// get the latest 10 tokens for local requests
43-
$tokens = $container->get('profiler')->find('127.0.0.1', '', 10, '', '');
42+
// get the latest 10 tokens for local POST requests
43+
$tokens = $container->get('profiler')->find('127.0.0.1', '', 10, 'POST', '', '');
4444

4545
// get the latest 10 tokens for requests that happened between 2 and 4 days ago
4646
$tokens = $container->get('profiler')
47-
->find('', '', 10, '4 days ago', '2 days ago');
47+
->find('', '', 10, '', '4 days ago', '2 days ago');
4848

4949
Lastly, if you want to manipulate profiling data on a different machine than the
5050
one where the information was generated, use the ``profiler:export`` and

cookbook/testing/doctrine.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ which makes all of this quite easy::
6060
protected function tearDown()
6161
{
6262
parent::tearDown();
63+
6364
$this->em->close();
65+
$this->em = null; // avoid memory leaks
6466
}
6567
}

reference/forms/types/entity.rst

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,29 @@ be listed inside the choice field::
6262
// ...
6363

6464
$builder->add('users', EntityType::class, array(
65+
// query choices from this entity
6566
'class' => 'AppBundle:User',
67+
68+
// use the User.username property as the visible option string
6669
'choice_label' => 'username',
70+
71+
// used to render a select box, check boxes or radios
72+
// 'multiple' => true,
73+
// 'expanded' => true,
6774
));
6875

69-
In this case, all ``User`` objects will be loaded from the database and
70-
rendered as either a ``select`` tag, a set or radio buttons or a series
71-
of checkboxes (this depends on the ``multiple`` and ``expanded`` values).
72-
Because of the `choice_label`_ option, the ``username`` property (usually by calling
73-
``getUsername()``) will be used as the text to display in the field.
76+
This will build a ``select`` drop-down containing *all* of the ``User`` objects
77+
in the database. To render radio buttons or checkboxes instead, change the
78+
`multiple`_ and `expanded`_ options.
7479

75-
If you omit the ``choice_label`` option, then your entity *must* have a ``__toString()``
76-
method.
80+
.. _ref-form-entity-query-builder:
7781

7882
Using a Custom Query for the Entities
7983
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8084

81-
If you need to specify a custom query to use when fetching the entities
85+
If you want to create a custom query to use when fetching the entities
8286
(e.g. you only want to return some entities, or need to order them), use
83-
the ``query_builder`` option. The easiest way to use the option is as follows::
87+
the `query_builder`_ option::
8488

8589
use Doctrine\ORM\EntityRepository;
8690
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -92,15 +96,17 @@ the ``query_builder`` option. The easiest way to use the option is as follows::
9296
return $er->createQueryBuilder('u')
9397
->orderBy('u.username', 'ASC');
9498
},
99+
'choice_label' => 'username',
95100
));
96101

97102
.. _reference-forms-entity-choices:
98103

99104
Using Choices
100105
~~~~~~~~~~~~~
101106

102-
If you already have the exact collection of entities that you want included
103-
in the choice element, you can simply pass them via the ``choices`` key.
107+
If you already have the exact collection of entities that you want to include
108+
in the choice element, just pass them via the ``choices`` key.
109+
104110
For example, if you have a ``$group`` variable (passed into your form perhaps
105111
as a form option) and ``getUsers`` returns a collection of ``User`` entities,
106112
then you can supply the ``choices`` option directly::
@@ -193,11 +199,12 @@ query_builder
193199

194200
**type**: ``Doctrine\ORM\QueryBuilder`` or a Closure
195201

196-
If specified, this is used to query the subset of options (and their
197-
order) that should be used for the field. The value of this option can
198-
either be a ``QueryBuilder`` object or a Closure. If using a Closure,
199-
it should take a single argument, which is the ``EntityRepository`` of
200-
the entity and return an instance of ``QueryBuilder``.
202+
Allows you to create a custom query for your choices. See
203+
:ref:`ref-form-entity-query-builder` for an example.
204+
205+
The value of this option can either be a ``QueryBuilder`` object or a Closure.
206+
When using a Closure, you will be passed the ``EntityRepository`` of the entity
207+
as the only argument and should return a ``QueryBuilder``.
201208

202209
Overridden Options
203210
------------------

0 commit comments

Comments
 (0)