Skip to content

Commit 4447b74

Browse files
committed
Merge branch '2.3' into 2.5
* 2.3: Fix up the final sentence to be a bit cleaner. SetDescription required on Product entities typo fix Fixed typo Modifying the best practice to use form_start() instead of <form Proposing that we make the service names *just* a little bit longer fix elseif statement Fixed wrong indentation Bot fixes tweaks to the Twig reference Removed unnecessary use statement in code example in the debugging cookbook Changed userName to username Update slash_in_parameter.rst Applied suggestion by Ryan Update form_customization.rst Merging emphasized notes Adder and remover sidenote Conflicts: reference/twig_reference.rst
2 parents 766e01f + 5db8386 commit 4447b74

File tree

16 files changed

+138
-97
lines changed

16 files changed

+138
-97
lines changed

best_practices/business-logic.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Next, define a new service for that class.
8181
# app/config/services.yml
8282
services:
8383
# keep your service names short
84-
slugger:
84+
app.slugger:
8585
class: AppBundle\Utils\Slugger
8686
8787
Traditionally, the naming convention for a service involved following the
@@ -92,7 +92,8 @@ your code will be easier to read and use.
9292
.. best-practice::
9393

9494
The name of your application's services should be as short as possible,
95-
ideally just one simple word.
95+
but unique enough that you can search your project for the service if
96+
you ever need to.
9697

9798
Now you can use the custom slugger in any controller class, such as the
9899
``AdminController``:
@@ -104,7 +105,7 @@ Now you can use the custom slugger in any controller class, such as the
104105
// ...
105106
106107
if ($form->isSubmitted() && $form->isValid()) {
107-
$slug = $this->get('slugger')->slugify($post->getTitle());
108+
$slug = $this->get('app.slugger')->slugify($post->getTitle());
108109
$post->setSlug($slug);
109110
110111
// ...
@@ -143,7 +144,7 @@ the class namespace as a parameter:
143144
slugger.class: AppBundle\Utils\Slugger
144145
145146
services:
146-
slugger:
147+
app.slugger:
147148
class: "%slugger.class%"
148149
149150
This practice is cumbersome and completely unnecessary for your own services:

best_practices/forms.rst

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -157,29 +157,15 @@ There are a lot of ways to render your form, ranging from rendering the entire
157157
thing in one line to rendering each part of each field independently. The
158158
best way depends on how much customization you need.
159159

160-
The simplest way - which is especially useful during development - is to render
161-
the form tags manually and then use ``form_widget()`` to render all of the fields:
160+
One of the simplest ways - which is especially useful during development -
161+
is to render the form tags and use ``form_widget()`` to render all of the
162+
fields:
162163

163164
.. code-block:: html+jinja
164165

165-
<form method="POST" {{ form_enctype(form) }}>
166+
{{ form_start(form, {'attr': {'class': 'my-form-class'} }) }}
166167
{{ form_widget(form) }}
167-
</form>
168-
169-
.. best-practice::
170-
171-
Don't use the ``form()`` or ``form_start()`` functions to render the
172-
starting and ending form tags.
173-
174-
Experienced Symfony developers will recognize that we're rendering the ``<form>``
175-
tags manually instead of using the ``form_start()`` or ``form()`` functions.
176-
While those are convenient, they take away from some clarity with little
177-
benefit.
178-
179-
.. tip::
180-
181-
The exception is a delete form because it's really just one button and
182-
so benefits from some of these extra shortcuts.
168+
{{ form_end(form) }}
183169

184170
If you need more control over how your fields are rendered, then you should
185171
remove the ``form_widget(form)`` function and render your fields individually.

book/doctrine.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,7 @@ Now you can see this new code in action! Imagine you're inside a controller::
11051105
$product = new Product();
11061106
$product->setName('Foo');
11071107
$product->setPrice(19.99);
1108+
$product->setDescription('Lorem ipsum dolor');
11081109
// relate this product to the category
11091110
$product->setCategory($category);
11101111

book/from_flat_php_to_symfony2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ on the requested URI:
367367
require_once 'controllers.php';
368368

369369
// route the request internally
370-
$uri = $_SERVER['REQUEST_URI'];
370+
$uri = parse_url(https://github.com/%3C/span%3E$_SERVER['REQUEST_URI']%3Cspan%20class=%22x%20x-first%20x-last%22%3E,%20PHP_URL_PATH);
371371
if ('/index.php' == $uri) {
372372
list_action();
373373
} elseif ('/index.php/show' == $uri && isset($_GET['id'])) {

contributing/documentation/overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Now you can **sync your fork** by executing the following command:
170170
$ git merge upstream/2.3
171171
172172
This command will update the ``2.3`` branch, which is the one you used to
173-
create the new branch for your changes. If have used another base branch,
173+
create the new branch for your changes. If you have used another base branch,
174174
e.g. ``master``, replace the ``2.3`` with the appropriate branch name.
175175

176176
Great! Now you can proceed by following the same steps explained in the previous

cookbook/debugging.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ below::
4747
$loader = require_once __DIR__.'/../app/autoload.php';
4848
require_once __DIR__.'/../app/AppKernel.php';
4949

50-
use Symfony\Component\HttpFoundation\Request;
51-
5250
$kernel = new AppKernel('dev', true);
5351
// $kernel->loadClassCache();
5452
$request = Request::createFromGlobals();

cookbook/form/form_collections.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,9 @@ we talk about next!).
463463

464464
.. caution::
465465

466-
If no ``addTag`` **and** ``removeTag`` method is found, the form will
467-
still use ``setTag`` even if ``by_reference`` is ``false``. You'll learn
468-
more about the ``removeTag`` method later in this article.
466+
You have to create **both** ``addTag`` and ``removeTag`` methods,
467+
otherwise the form will still use ``setTag`` even if ``by_reference`` is ``false``.
468+
You'll learn more about the ``removeTag`` method later in this article.
469469

470470
.. sidebar:: Doctrine: Cascading Relations and saving the "Inverse" side
471471

cookbook/form/form_customization.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,19 @@ just one line:
6767

6868
.. code-block:: jinja
6969
70+
{# renders all fields #}
7071
{{ form_widget(form) }}
7172
73+
{# renders all fields *and* the form start and end tags #}
74+
{{ form(form) }}
75+
7276
.. code-block:: php
7377
74-
<?php echo $view['form']->widget($form); ?>
78+
<!-- renders all fields -->
79+
<?php echo $view['form']->widget($form) ?>
80+
81+
<!-- renders all fields *and* the form start and end tags -->
82+
<?php echo $view['form']->form($form) ?>
7583
7684
The remainder of this recipe will explain how every part of the form's markup
7785
can be modified at several different levels. For more information about form

cookbook/routing/slash_in_parameter.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ How to Allow a "/" Character in a Route Parameter
55
=================================================
66

77
Sometimes, you need to compose URLs with parameters that can contain a slash
8-
``/``. For example, take the classic ``/hello/{name}`` route. By default,
8+
``/``. For example, take the classic ``/hello/{username}`` route. By default,
99
``/hello/Fabien`` will match this route but not ``/hello/Fabien/Kris``. This
1010
is because Symfony uses this character as separator between route parts.
1111

1212
This guide covers how you can modify a route so that ``/hello/Fabien/Kris``
13-
matches the ``/hello/{name}`` route, where ``{name}`` equals ``Fabien/Kris``.
13+
matches the ``/hello/{username}`` route, where ``{username}`` equals ``Fabien/Kris``.
1414

1515
Configure the Route
1616
-------------------
@@ -27,10 +27,10 @@ a more permissive regex path.
2727
.. code-block:: yaml
2828
2929
_hello:
30-
path: /hello/{name}
30+
path: /hello/{username}
3131
defaults: { _controller: AcmeDemoBundle:Demo:hello }
3232
requirements:
33-
name: .+
33+
username: .+
3434
3535
.. code-block:: xml
3636
@@ -40,9 +40,9 @@ a more permissive regex path.
4040
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4141
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
4242
43-
<route id="_hello" path="/hello/{name}">
43+
<route id="_hello" path="/hello/{username}">
4444
<default key="_controller">AcmeDemoBundle:Demo:hello</default>
45-
<requirement key="name">.+</requirement>
45+
<requirement key="username">.+</requirement>
4646
</route>
4747
</routes>
4848
@@ -52,10 +52,10 @@ a more permissive regex path.
5252
use Symfony\Component\Routing\Route;
5353
5454
$collection = new RouteCollection();
55-
$collection->add('_hello', new Route('/hello/{name}', array(
55+
$collection->add('_hello', new Route('/hello/{username}', array(
5656
'_controller' => 'AcmeDemoBundle:Demo:hello',
5757
), array(
58-
'name' => '.+',
58+
'username' => '.+',
5959
)));
6060
6161
return $collection;
@@ -75,4 +75,4 @@ a more permissive regex path.
7575
}
7676
}
7777
78-
That's it! Now, the ``{name}`` parameter can contain the ``/`` character.
78+
That's it! Now, the ``{username}`` parameter can contain the ``/`` character.

cookbook/security/target_path.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ Next, create your own ``ExceptionListener``::
6767
}
6868
}
6969

70-
Add as much or few logic here as required for your scenario!
70+
Add as much or as little logic here as required for your scenario!

reference/configuration/assetic.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
AsseticBundle Configuration ("assetic")
55
=======================================
66

7-
Full default Configuration
8-
~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
Full Default Configuration
8+
--------------------------
99

1010
.. configuration-block::
1111

reference/configuration/doctrine.rst

Lines changed: 65 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
DoctrineBundle Configuration ("doctrine")
66
=========================================
77

8-
Full default configuration
8+
Full Default Configuration
99
--------------------------
1010

1111
.. configuration-block::
@@ -180,8 +180,10 @@ Full default configuration
180180
<container xmlns="http://symfony.com/schema/dic/services"
181181
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
182182
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
183-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
184-
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
183+
xsi:schemaLocation="http://symfony.com/schema/dic/services
184+
http://symfony.com/schema/dic/services/services-1.0.xsd
185+
http://symfony.com/schema/dic/doctrine
186+
http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
185187
186188
<doctrine:config>
187189
<doctrine:dbal default-connection="default">
@@ -209,16 +211,44 @@ Full default configuration
209211
<doctrine:type name="custom">Acme\HelloBundle\MyCustomType</doctrine:type>
210212
</doctrine:dbal>
211213
212-
<doctrine:orm default-entity-manager="default" auto-generate-proxy-classes="false" proxy-namespace="Proxies" proxy-dir="%kernel.cache_dir%/doctrine/orm/Proxies">
213-
<doctrine:entity-manager name="default" query-cache-driver="array" result-cache-driver="array" connection="conn1" class-metadata-factory-name="Doctrine\ORM\Mapping\ClassMetadataFactory">
214-
<doctrine:metadata-cache-driver type="memcache" host="localhost" port="11211" instance-class="Memcache" class="Doctrine\Common\Cache\MemcacheCache" />
214+
<doctrine:orm
215+
default-entity-manager="default"
216+
auto-generate-proxy-classes="false"
217+
proxy-namespace="Proxies"
218+
proxy-dir="%kernel.cache_dir%/doctrine/orm/Proxies"
219+
>
220+
<doctrine:entity-manager
221+
name="default"
222+
query-cache-driver="array"
223+
result-cache-driver="array"
224+
connection="conn1"
225+
class-metadata-factory-name="Doctrine\ORM\Mapping\ClassMetadataFactory"
226+
>
227+
<doctrine:metadata-cache-driver
228+
type="memcache"
229+
host="localhost"
230+
port="11211"
231+
instance-class="Memcache"
232+
class="Doctrine\Common\Cache\MemcacheCache"
233+
/>
234+
215235
<doctrine:mapping name="AcmeHelloBundle" />
236+
216237
<doctrine:dql>
217-
<doctrine:string-function name="test_string">Acme\HelloBundle\DQL\StringFunction</doctrine:string-function>
218-
<doctrine:numeric-function name="test_numeric">Acme\HelloBundle\DQL\NumericFunction</doctrine:numeric-function>
219-
<doctrine:datetime-function name="test_datetime">Acme\HelloBundle\DQL\DatetimeFunction</doctrine:datetime-function>
238+
<doctrine:string-function name="test_string">
239+
Acme\HelloBundle\DQL\StringFunction
240+
</doctrine:string-function>
241+
242+
<doctrine:numeric-function name="test_numeric">
243+
Acme\HelloBundle\DQL\NumericFunction
244+
</doctrine:numeric-function>
245+
246+
<doctrine:datetime-function name="test_datetime">
247+
Acme\HelloBundle\DQL\DatetimeFunction
248+
</doctrine:datetime-function>
220249
</doctrine:dql>
221250
</doctrine:entity-manager>
251+
222252
<doctrine:entity-manager name="em2" connection="conn2" metadata-cache-driver="apc">
223253
<doctrine:mapping
224254
name="DoctrineExtensions"
@@ -235,8 +265,8 @@ Full default configuration
235265
Configuration Overview
236266
----------------------
237267

238-
This following configuration example shows all the configuration defaults that
239-
the ORM resolves to:
268+
This following configuration example shows all the configuration defaults
269+
that the ORM resolves to:
240270

241271
.. code-block:: yaml
242272
@@ -258,8 +288,8 @@ certain classes, but those are for very advanced use-cases only.
258288
Caching Drivers
259289
~~~~~~~~~~~~~~~
260290

261-
For the caching drivers you can specify the values "array", "apc", "memcache", "memcached",
262-
"xcache" or "service".
291+
For the caching drivers you can specify the values "array", "apc", "memcache",
292+
"memcached", "xcache" or "service".
263293

264294
The following example shows an overview of the caching configurations:
265295

@@ -282,34 +312,34 @@ Mapping Configuration
282312
~~~~~~~~~~~~~~~~~~~~~
283313

284314
Explicit definition of all the mapped entities is the only necessary
285-
configuration for the ORM and there are several configuration options that you
286-
can control. The following configuration options exist for a mapping:
315+
configuration for the ORM and there are several configuration options that
316+
you can control. The following configuration options exist for a mapping:
287317

288318
* ``type`` One of ``annotation``, ``xml``, ``yml``, ``php`` or ``staticphp``.
289319
This specifies which type of metadata type your mapping uses.
290320

291-
* ``dir`` Path to the mapping or entity files (depending on the driver). If
292-
this path is relative it is assumed to be relative to the bundle root. This
293-
only works if the name of your mapping is a bundle name. If you want to use
294-
this option to specify absolute paths you should prefix the path with the
295-
kernel parameters that exist in the DIC (for example %kernel.root_dir%).
321+
* ``dir`` Path to the mapping or entity files (depending on the driver).
322+
If this path is relative it is assumed to be relative to the bundle root.
323+
This only works if the name of your mapping is a bundle name. If you want
324+
to use this option to specify absolute paths you should prefix the path
325+
with the kernel parameters that exist in the DIC (for example ``%kernel.root_dir%``).
296326

297327
* ``prefix`` A common namespace prefix that all entities of this mapping
298328
share. This prefix should never conflict with prefixes of other defined
299-
mappings otherwise some of your entities cannot be found by Doctrine. This
300-
option defaults to the bundle namespace + ``Entity``, for example for an
301-
application bundle called ``AcmeHelloBundle`` prefix would be
329+
mappings otherwise some of your entities cannot be found by Doctrine.
330+
This option defaults to the bundle namespace + ``Entity``, for example
331+
for an application bundle called ``AcmeHelloBundle`` prefix would be
302332
``Acme\HelloBundle\Entity``.
303333

304334
* ``alias`` Doctrine offers a way to alias entity namespaces to simpler,
305-
shorter names to be used in DQL queries or for Repository access. When using
306-
a bundle the alias defaults to the bundle name.
335+
shorter names to be used in DQL queries or for Repository access. When
336+
using a bundle the alias defaults to the bundle name.
307337

308-
* ``is_bundle`` This option is a derived value from ``dir`` and by default is
309-
set to true if dir is relative proved by a ``file_exists()`` check that
310-
returns false. It is false if the existence check returns true. In this case
311-
an absolute path was specified and the metadata files are most likely in a
312-
directory outside of a bundle.
338+
* ``is_bundle`` This option is a derived value from ``dir`` and by default
339+
is set to true if dir is relative proved by a ``file_exists()`` check
340+
that returns false. It is false if the existence check returns true. In
341+
this case an absolute path was specified and the metadata files are most
342+
likely in a directory outside of a bundle.
313343

314344
.. index::
315345
single: Configuration; Doctrine DBAL
@@ -363,8 +393,11 @@ The following block shows all possible configuration keys:
363393
<container xmlns="http://symfony.com/schema/dic/services"
364394
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
365395
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
366-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
367-
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
396+
xsi:schemaLocation="http://symfony.com/schema/dic/services
397+
http://symfony.com/schema/dic/services/services-1.0.xsd
398+
http://symfony.com/schema/dic/doctrine
399+
http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"
400+
>
368401
369402
<doctrine:config>
370403
<doctrine:dbal

0 commit comments

Comments
 (0)