Skip to content

Commit 2038123

Browse files
committed
Merge branch '2.3' into 2.7
Conflicts: reference/forms/types/entity.rst
2 parents 32f2f18 + 7a3eca6 commit 2038123

File tree

9 files changed

+88
-37
lines changed

9 files changed

+88
-37
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/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: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,47 +59,56 @@ The ``entity`` type has just one required option: the entity which should
5959
be listed inside the choice field::
6060

6161
$builder->add('users', 'entity', array(
62-
'class' => 'AcmeHelloBundle:User',
62+
// query choices from this entity
63+
'class' => 'AppBundle:User',
64+
65+
// use the User.username property as the visible option string
6366
'choice_label' => 'username',
67+
68+
// used to render a select box, check boxes or radios
69+
// 'multiple' => true,
70+
// 'expanded' => true,
6471
));
6572

66-
In this case, all ``User`` objects will be loaded from the database and
67-
rendered as either a ``select`` tag, a set or radio buttons or a series
68-
of checkboxes (this depends on the ``multiple`` and ``expanded`` values).
69-
If the entity object does not have a ``__toString()`` method the ``choice_label``
70-
option is needed.
73+
This will build a ``select`` drop-down containing *all* of the ``User`` objects
74+
in the database. To render radio buttons or checkboxes instead, change the
75+
`multiple`_ and `expanded`_ options.
76+
77+
.. _ref-form-entity-query-builder:
7178

7279
Using a Custom Query for the Entities
7380
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7481

75-
If you need to specify a custom query to use when fetching the entities
82+
If you want to create a custom query to use when fetching the entities
7683
(e.g. you only want to return some entities, or need to order them), use
77-
the ``query_builder`` option. The easiest way to use the option is as follows::
84+
the `query_builder`_ option::
7885

7986
use Doctrine\ORM\EntityRepository;
8087
// ...
8188

8289
$builder->add('users', 'entity', array(
83-
'class' => 'AcmeHelloBundle:User',
90+
'class' => 'AppBundle:User',
8491
'query_builder' => function (EntityRepository $er) {
8592
return $er->createQueryBuilder('u')
8693
->orderBy('u.username', 'ASC');
8794
},
95+
'choice_label' => 'username',
8896
));
8997

9098
.. _reference-forms-entity-choices:
9199

92100
Using Choices
93101
~~~~~~~~~~~~~
94102

95-
If you already have the exact collection of entities that you want included
96-
in the choice element, you can simply pass them via the ``choices`` key.
103+
If you already have the exact collection of entities that you want to include
104+
in the choice element, just pass them via the ``choices`` key.
105+
97106
For example, if you have a ``$group`` variable (passed into your form perhaps
98107
as a form option) and ``getUsers`` returns a collection of ``User`` entities,
99108
then you can supply the ``choices`` option directly::
100109

101110
$builder->add('users', 'entity', array(
102-
'class' => 'AcmeHelloBundle:User',
111+
'class' => 'AppBundle:User',
103112
'choices' => $group->getUsers(),
104113
));
105114

@@ -157,8 +166,8 @@ class
157166

158167
**type**: ``string`` **required**
159168

160-
The class of your entity (e.g. ``AcmeStoreBundle:Category``). This can be
161-
a fully-qualified class name (e.g. ``Acme\StoreBundle\Entity\Category``)
169+
The class of your entity (e.g. ``AppBundle:Category``). This can be
170+
a fully-qualified class name (e.g. ``AppBundle\Entity\Category``)
162171
or the short alias name (as shown prior).
163172

164173
em
@@ -174,11 +183,12 @@ query_builder
174183

175184
**type**: ``Doctrine\ORM\QueryBuilder`` or a Closure
176185

177-
If specified, this is used to query the subset of options (and their
178-
order) that should be used for the field. The value of this option can
179-
either be a ``QueryBuilder`` object or a Closure. If using a Closure,
180-
it should take a single argument, which is the ``EntityRepository`` of
181-
the entity and return an instance of ``QueryBuilder``.
186+
Allows you to create a custom query for your choices. See
187+
:ref:`ref-form-entity-query-builder` for an example.
188+
189+
The value of this option can either be a ``QueryBuilder`` object or a Closure.
190+
When using a Closure, you will be passed the ``EntityRepository`` of the entity
191+
as the only argument and should return a ``QueryBuilder``.
182192

183193
Overridden Options
184194
------------------

0 commit comments

Comments
 (0)