Skip to content

Commit 95e651f

Browse files
committed
Merge branch '2.3'
2 parents f897411 + b4bcd86 commit 95e651f

File tree

19 files changed

+212
-191
lines changed

19 files changed

+212
-191
lines changed

book/doctrine.rst

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
960960
<entity name="Acme\StoreBundle\Entity\Category">
961961
<!-- ... -->
962962
<one-to-many field="products"
963-
target-entity="product"
963+
target-entity="Product"
964964
mapped-by="category"
965965
/>
966966
@@ -988,7 +988,7 @@ makes sense in the application for each ``Category`` to hold an array of
988988
.. tip::
989989

990990
The targetEntity value in the decorator used above can reference any entity
991-
with a valid namespace, not just entities defined in the same class. To
991+
with a valid namespace, not just entities defined in the same namespace. To
992992
relate to an entity defined in a different class or bundle, enter a full
993993
namespace as the targetEntity.
994994

@@ -1038,7 +1038,8 @@ object, you'll want to add a ``$category`` property to the ``Product`` class:
10381038
<entity name="Acme\StoreBundle\Entity\Product">
10391039
<!-- ... -->
10401040
<many-to-one field="category"
1041-
target-entity="products"
1041+
target-entity="Category"
1042+
inversed-by="products"
10421043
join-column="category"
10431044
>
10441045
<join-column
@@ -1205,14 +1206,14 @@ to the given ``Category`` object via their ``category_id`` value.
12051206

12061207
The proxy classes are generated by Doctrine and stored in the cache directory.
12071208
And though you'll probably never even notice that your ``$category``
1208-
object is actually a proxy object, it's important to keep in mind.
1209+
object is actually a proxy object, it's important to keep it in mind.
12091210

12101211
In the next section, when you retrieve the product and category data
12111212
all at once (via a *join*), Doctrine will return the *true* ``Category``
12121213
object, since nothing needs to be lazily loaded.
12131214

1214-
Joining to Related Records
1215-
~~~~~~~~~~~~~~~~~~~~~~~~~~
1215+
Joining Related Records
1216+
~~~~~~~~~~~~~~~~~~~~~~~
12161217

12171218
In the above examples, two queries were made - one for the original object
12181219
(e.g. a ``Category``) and one for the related object(s) (e.g. the ``Product``
@@ -1304,7 +1305,7 @@ callbacks. This is not necessary if you're using YAML or XML for your mapping:
13041305
}
13051306
13061307
Now, you can tell Doctrine to execute a method on any of the available lifecycle
1307-
events. For example, suppose you want to set a ``created`` date column to
1308+
events. For example, suppose you want to set a ``createdAt`` date column to
13081309
the current date, only when the entity is first persisted (i.e. inserted):
13091310

13101311
.. configuration-block::
@@ -1314,9 +1315,9 @@ the current date, only when the entity is first persisted (i.e. inserted):
13141315
/**
13151316
* @ORM\PrePersist
13161317
*/
1317-
public function setCreatedValue()
1318+
public function setCreatedAtValue()
13181319
{
1319-
$this->created = new \DateTime();
1320+
$this->createdAt = new \DateTime();
13201321
}
13211322
13221323
.. code-block:: yaml
@@ -1326,7 +1327,7 @@ the current date, only when the entity is first persisted (i.e. inserted):
13261327
type: entity
13271328
# ...
13281329
lifecycleCallbacks:
1329-
prePersist: [setCreatedValue]
1330+
prePersist: [setCreatedAtValue]
13301331
13311332
.. code-block:: xml
13321333
@@ -1339,18 +1340,18 @@ the current date, only when the entity is first persisted (i.e. inserted):
13391340
<!-- ... -->
13401341
<lifecycle-callbacks>
13411342
<lifecycle-callback type="prePersist"
1342-
method="setCreatedValue" />
1343+
method="setCreatedAtValue" />
13431344
</lifecycle-callbacks>
13441345
</entity>
13451346
</doctrine-mapping>
13461347
13471348
.. note::
13481349

1349-
The above example assumes that you've created and mapped a ``created``
1350+
The above example assumes that you've created and mapped a ``createdAt``
13501351
property (not shown here).
13511352

13521353
Now, right before the entity is first persisted, Doctrine will automatically
1353-
call this method and the ``created`` field will be set to the current date.
1354+
call this method and the ``createdAt`` field will be set to the current date.
13541355

13551356
This can be repeated for any of the other lifecycle events, which include:
13561357

@@ -1368,7 +1369,7 @@ in general, see Doctrine's `Lifecycle Events documentation`_
13681369

13691370
.. sidebar:: Lifecycle Callbacks and Event Listeners
13701371

1371-
Notice that the ``setCreatedValue()`` method receives no arguments. This
1372+
Notice that the ``setCreatedAtValue()`` method receives no arguments. This
13721373
is always the case for lifecycle callbacks and is intentional: lifecycle
13731374
callbacks should be simple methods that are concerned with internally
13741375
transforming data in the entity (e.g. setting a created/updated field,

book/forms.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ guess from the validation rules that both the ``task`` field is a normal
654654
$form = $this->createFormBuilder($task)
655655
->add('task')
656656
->add('dueDate', null, array('widget' => 'single_text'))
657+
->add('save', 'submit')
657658
->getForm();
658659
}
659660

@@ -918,6 +919,7 @@ ways. If you build your form in the controller, you can use ``setAction()`` and
918919
->setMethod('GET')
919920
->add('task', 'text')
920921
->add('dueDate', 'date')
922+
->add('save', 'submit')
921923
->getForm();
922924

923925
.. note::
@@ -991,8 +993,9 @@ that will house the logic for building the task form::
991993
{
992994
public function buildForm(FormBuilderInterface $builder, array $options)
993995
{
994-
$builder->add('task');
995-
$builder->add('dueDate', null, array('widget' => 'single_text'));
996+
$builder->add('task')
997+
->add('dueDate', null, array('widget' => 'single_text'))
998+
->add('save', 'submit');
996999
}
9971000

9981001
public function getName()
@@ -1057,8 +1060,9 @@ the choice is ultimately up to you.
10571060

10581061
public function buildForm(FormBuilderInterface $builder, array $options)
10591062
{
1060-
$builder->add('task');
1061-
$builder->add('dueDate', null, array('mapped' => false));
1063+
$builder->add('task')
1064+
->add('dueDate', null, array('mapped' => false))
1065+
->add('save', 'submit');
10621066
}
10631067

10641068
Additionally, if there are any fields on the form that aren't included in
@@ -1731,6 +1735,7 @@ an array of the submitted data. This is actually really easy::
17311735
->add('name', 'text')
17321736
->add('email', 'email')
17331737
->add('message', 'textarea')
1738+
->add('send', 'submit')
17341739
->getForm();
17351740

17361741
$form->handleRequest($request);

book/http_fundamentals.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ by adding an entry for ``/contact`` to your routing configuration file:
430430
.. code-block:: xml
431431
432432
<route id="contact" path="/contact">
433-
<default key="_controller">AcmeBlogBundle:Main:contact</default>
433+
<default key="_controller">AcmeDemoBundle:Main:contact</default>
434434
</route>
435435
436436
.. code-block:: php
@@ -441,7 +441,7 @@ by adding an entry for ``/contact`` to your routing configuration file:
441441
442442
$collection = new RouteCollection();
443443
$collection->add('contact', new Route('/contact', array(
444-
'_controller' => 'AcmeBlogBundle:Main:contact',
444+
'_controller' => 'AcmeDemoBundle:Main:contact',
445445
)));
446446
447447
return $collection;

book/installation.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ All public files and the front controller that handles incoming requests in
127127
a Symfony2 application live in the ``Symfony/web/`` directory. So, assuming
128128
you unpacked the archive into your web server's or virtual host's document root,
129129
your application's URLs will start with ``http://localhost/Symfony/web/``.
130-
To get nice and short URLs you should point the document root of your web
131-
server or virtual host to the ``Symfony/web/`` directory. Though this is not
132-
required for development it is recommended when your application goes into
133-
production as all system and configuration files become inaccessible to clients.
134-
For information on configuring your specific web server document root, see
135-
the following documentation: `Apache`_ | `Nginx`_ .
136130

137131
.. note::
138132

book/page_creation.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,42 @@ HTTP response.
2222
Symfony2 follows this philosophy and provides you with tools and conventions
2323
to keep your application organized as it grows in users and complexity.
2424

25+
.. index::
26+
single: Page creation; Environments & Front Controllers
27+
28+
.. _page-creation-environments:
29+
30+
Environments & Front Controllers
31+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32+
33+
Every Symfony application runs within an :term:`environment`. An environment
34+
is a specific set of configuration and loaded bundles, represented by a string.
35+
The same application can be run with different configurations by running the
36+
application in different environments. Symfony2 comes with three environments
37+
defined — ``dev``, ``test`` and ``prod`` — but you can create your own as well.
38+
39+
Environments are useful by allowing a single application to have a dev environment
40+
built for debugging and a production environment optimized for speed. You might
41+
also load specific bundles based on the selected environment. For example,
42+
Symfony2 comes with the WebProfilerBundle (described below), enabled only
43+
in the ``dev`` and ``test`` environments.
44+
45+
Symfony2 comes with two web-accessible front controllers: ``app_dev.php``
46+
provides the ``dev`` environment, and ``app.php`` provides the ``prod`` environment.
47+
All web accesses to Symfony2 normally go through one of these front controllers.
48+
(The ``test`` environment is normally only used when running unit tests, and so
49+
doesn't have a dedicated front controller. The console tool also provides a
50+
front controller that can be used with any environment.)
51+
52+
When the front controller initializes the kernel, it provides two parameters:
53+
the environment, and also whether the kernel should run in debug mode.
54+
To make your application respond faster, Symfony2 maintains a cache under the
55+
``app/cache/`` directory. When in debug mode is enabled (such as ``app_dev.php``
56+
does by default), this cache is flushed automatically whenever you make changes
57+
to any code or configuration. When running in debug mode, Symfony2 runs
58+
slower, but your changes are reflected without having to manually clear the
59+
cache.
60+
2561
.. index::
2662
single: Page creation; Example
2763

book/propel.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ Create the classes:
353353
354354
$ php app/console propel:model:build
355355
356-
Assuming you have products in your database, you don't want lose them. Thanks to
356+
Assuming you have products in your database, you don't want to lose them. Thanks to
357357
migrations, Propel will be able to update your database without losing existing
358358
data.
359359

@@ -362,7 +362,7 @@ data.
362362
$ php app/console propel:migration:generate-diff
363363
$ php app/console propel:migration:migrate
364364
365-
Your database has been updated, you can continue to write your application.
365+
Your database has been updated, you can continue writing your application.
366366

367367
Saving Related Objects
368368
~~~~~~~~~~~~~~~~~~~~~~

book/templating.rst

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Creating and using Templates
66

77
As you know, the :doc:`controller </book/controller>` is responsible for
88
handling each request that comes into a Symfony2 application. In reality,
9-
the controller delegates the most of the heavy work to other places so that
9+
the controller delegates most of the heavy work to other places so that
1010
code can be tested and reused. When a controller needs to generate HTML,
1111
CSS or any other content, it hands the work off to the templating engine.
1212
In this chapter, you'll learn how to write powerful templates that can be
@@ -204,10 +204,10 @@ First, build a base layout file:
204204
<body>
205205
<div id="sidebar">
206206
{% block sidebar %}
207-
<ul>
208-
<li><a href="/">Home</a></li>
209-
<li><a href="/blog">Blog</a></li>
210-
</ul>
207+
<ul>
208+
<li><a href="/">Home</a></li>
209+
<li><a href="/blog">Blog</a></li>
210+
</ul>
211211
{% endblock %}
212212
</div>
213213

@@ -561,8 +561,10 @@ Including this template from any other template is simple:
561561

562562
The template is included using the ``{{ include() }}`` function. Notice that the
563563
template name follows the same typical convention. The ``articleDetails.html.twig``
564-
template uses an ``article`` variable. This is passed in by the ``list.html.twig``
565-
template using the ``with`` command.
564+
template uses an ``article`` variable, which we pass to it. In this case,
565+
you could avoid doing this entirely, as all of the variables available in
566+
``list.html.twig`` are also available in ``articleDetails.html.twig`` (unless
567+
you set `with_context`_ to false).
566568

567569
.. tip::
568570

@@ -571,8 +573,8 @@ template using the ``with`` command.
571573
elements, it would look like this: ``{'foo': foo, 'bar': bar}``.
572574

573575
.. versionadded:: 2.2
574-
The ``include()`` function is a new Twig feature that's available in
575-
Symfony 2.2. Prior, the ``{% include %}`` tag was used.
576+
The `include() function`_ is a new Twig feature that's available in Symfony
577+
2.2. Prior, the `{% include %} tag`_ tag was used.
576578

577579
.. index::
578580
single: Templating; Embedding action
@@ -1391,8 +1393,6 @@ in a JavaScript string, use the ``js`` context:
13911393
.. index::
13921394
single: Templating; Formats
13931395

1394-
.. _template-formats:
1395-
13961396
Debugging
13971397
---------
13981398

@@ -1434,6 +1434,8 @@ console command:
14341434
# or using the bundle name:
14351435
$ php app/console twig:lint @AcmeArticleBundle
14361436
1437+
.. _template-formats:
1438+
14371439
Template Formats
14381440
----------------
14391441

@@ -1529,3 +1531,6 @@ Learn more from the Cookbook
15291531
.. _`filters`: http://twig.sensiolabs.org/doc/filters/index.html
15301532
.. _`add your own extensions`: http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension
15311533
.. _`hinclude.js`: http://mnot.github.com/hinclude/
1534+
.. _`with_context`: http://twig.sensiolabs.org/doc/functions/include.html
1535+
.. _`include() function`: http://twig.sensiolabs.org/doc/functions/include.html
1536+
.. _`{% include %} tag`: http://twig.sensiolabs.org/doc/tags/include.html

book/testing.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,7 @@ narrow down your node selection by chaining the method calls::
544544

545545
$crawler
546546
->filter('h1')
547-
->reduce(function ($node, $i)
548-
{
547+
->reduce(function ($node, $i) {
549548
if (!$node->getAttribute('class')) {
550549
return false;
551550
}

components/dependency_injection/advanced.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Synthetic services are services that are injected into the container instead
6666
of being created by the container.
6767

6868
For example, if you're using the :doc:`HttpKernel</components/http_kernel/introduction>`
69-
component with the DependencyInjection component, then the the ``request``
69+
component with the DependencyInjection component, then the ``request``
7070
service is injected in the
7171
:method:`ContainerAwareHttpKernel::handle() <Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel::handle>`
7272
method when entering the request :doc:`scope </cookbook/service_container/scopes>`.

components/event_dispatcher/introduction.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ or after a method is executed, without interfering with other plugins. This is
2020
not an easy problem to solve with single inheritance, and multiple inheritance
2121
(were it possible with PHP) has its own drawbacks.
2222

23-
The Symfony2 Event Dispatcher component implements the `Observer`_ pattern in
23+
The Symfony2 Event Dispatcher component implements the `Mediator`_ pattern in
2424
a simple and effective way to make all these things possible and to make your
2525
projects truly extensible.
2626

@@ -588,7 +588,7 @@ part of the listener's processing logic::
588588
}
589589
}
590590

591-
.. _Observer: http://en.wikipedia.org/wiki/Observer_pattern
591+
.. _Mediator: http://en.wikipedia.org/wiki/Mediator_pattern
592592
.. _Closures: http://php.net/manual/en/functions.anonymous.php
593593
.. _PHP callable: http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback
594594
.. _Packagist: https://packagist.org/packages/symfony/event-dispatcher

0 commit comments

Comments
 (0)