Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dbf92bc

Browse files
author
Michael Klein
committed
Merge pull request #1 from symfony/master
update to latest
2 parents 5f69c8f + f3e9d17 commit dbf92bc

File tree

183 files changed

+1418
-827
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+1418
-827
lines changed

book/controller.rst

100644100755
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ see :ref:`controller-string-syntax`.
196196

197197
.. tip::
198198

199-
You can learn much more about the routing system in the :doc:`Routing chapter</book/routing>`.
199+
You can learn much more about the routing system in the :doc:`Routing chapter </book/routing>`.
200200

201201
.. index::
202202
single: Controller; Controller arguments
@@ -392,12 +392,17 @@ itself.
392392

393393
Extending the base class is *optional* in Symfony; it contains useful
394394
shortcuts but nothing mandatory. You can also extend
395-
:class:`Symfony\\Component\\DependencyInjection\\ContainerAware`. The service
396-
container object will then be accessible via the ``container`` property.
395+
:class:`Symfony\\Component\\DependencyInjection\\ContainerAware` or use
396+
the class:`Symfony\\Component\\DependencyInjection\\ContainerAwareTrait` trait
397+
(if you have PHP 5.4). The service container object will then be accessible
398+
via the ``container`` property.
399+
400+
.. versionadded:: 2.4
401+
The ``ContainerAwareTrait`` is new in Symfony 2.4.
397402

398403
.. note::
399404

400-
You can also define your :doc:`Controllers as Services</cookbook/controller/service>`.
405+
You can also define your :doc:`Controllers as Services </cookbook/controller/service>`.
401406
This is optional, but can give you more control over the exact dependencies
402407
that are injected into your controllers.
403408

@@ -494,10 +499,10 @@ value to each variable.
494499
Like other base ``Controller`` methods, the ``forward`` method is just
495500
a shortcut for core Symfony2 functionality. A forward can be accomplished
496501
directly by duplicating the current request. When this
497-
:ref:`sub request<http-kernel-sub-requests>` is executed via the ``http_kernel``
502+
:ref:`sub request <http-kernel-sub-requests>` is executed via the ``http_kernel``
498503
service the ``HttpKernel`` returns a ``Response`` object::
499504
500-
use Symfony\Component\HttpKernel/HttpKernelInterface;
505+
use Symfony\Component\HttpKernel\HttpKernelInterface;
501506
502507
$path = array(
503508
'_controller' => 'AcmeHelloBundle:Hello:fancy',
@@ -549,7 +554,8 @@ The Symfony templating engine is explained in great detail in the
549554
.. tip::
550555

551556
You can even avoid calling the ``render`` method by using the ``@Template``
552-
annotation. See the :doc:`FrameworkExtraBundle documentation</bundles/SensioFrameworkExtraBundle/annotations/view>`
557+
annotation. See the
558+
:doc:`FrameworkExtraBundle documentation </bundles/SensioFrameworkExtraBundle/annotations/view>`
553559
more details.
554560

555561
.. tip::

book/doctrine.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ in a number of different formats including YAML, XML or directly inside the
272272
class Product
273273
{
274274
/**
275-
* @ORM\Id
276275
* @ORM\Column(type="integer")
276+
* @ORM\Id
277277
* @ORM\GeneratedValue(strategy="AUTO")
278278
*/
279279
protected $id;
@@ -473,7 +473,7 @@ in your application. To do this, run:
473473
new column to the existing ``product`` table.
474474

475475
An even better way to take advantage of this functionality is via
476-
:doc:`migrations</bundles/DoctrineMigrationsBundle/index>`, which allow you to
476+
:doc:`migrations </bundles/DoctrineMigrationsBundle/index>`, which allow you to
477477
generate these SQL statements and store them in migration classes that
478478
can be run systematically on your production server in order to track
479479
and migrate your database schema safely and reliably.
@@ -581,7 +581,7 @@ on its ``id`` value::
581581

582582
You can achieve the equivalent of this without writing any code by using
583583
the ``@ParamConverter`` shortcut. See the
584-
:doc:`FrameworkExtraBundle documentation</bundles/SensioFrameworkExtraBundle/annotations/converters>`
584+
:doc:`FrameworkExtraBundle documentation </bundles/SensioFrameworkExtraBundle/annotations/converters>`
585585
for more details.
586586

587587
When you query for a particular type of object, you always use what's known
@@ -758,7 +758,7 @@ for just one object, you can use the ``getSingleResult()`` method instead::
758758
// ...
759759

760760
The DQL syntax is incredibly powerful, allowing you to easily join between
761-
entities (the topic of :ref:`relations<book-doctrine-relations>` will be
761+
entities (the topic of :ref:`relations <book-doctrine-relations>` will be
762762
covered later), group, etc. For more information, see the official Doctrine
763763
`Doctrine Query Language`_ documentation.
764764

@@ -1112,7 +1112,7 @@ table, and ``product.category_id`` column, and new foreign key:
11121112

11131113
This task should only be really used during development. For a more robust
11141114
method of systematically updating your production database, read about
1115-
:doc:`Doctrine migrations</bundles/DoctrineMigrationsBundle/index>`.
1115+
:doc:`Doctrine migrations </bundles/DoctrineMigrationsBundle/index>`.
11161116

11171117
Saving Related Entities
11181118
~~~~~~~~~~~~~~~~~~~~~~~
@@ -1300,7 +1300,7 @@ Configuration
13001300

13011301
Doctrine is highly configurable, though you probably won't ever need to worry
13021302
about most of its options. To find out more about configuring Doctrine, see
1303-
the Doctrine section of the :doc:`reference manual</reference/configuration/doctrine>`.
1303+
the Doctrine section of the :doc:`reference manual </reference/configuration/doctrine>`.
13041304

13051305
Lifecycle Callbacks
13061306
-------------------
@@ -1412,7 +1412,7 @@ These include thing such as *Sluggable*, *Timestampable*, *Loggable*, *Translata
14121412
and *Tree*.
14131413

14141414
For more information on how to find and use these extensions, see the cookbook
1415-
article about :doc:`using common Doctrine extensions</cookbook/doctrine/common_extensions>`.
1415+
article about :doc:`using common Doctrine extensions </cookbook/doctrine/common_extensions>`.
14161416

14171417
.. _book-doctrine-field-types:
14181418

@@ -1591,7 +1591,7 @@ that allow you to take different actions as objects go through their persistence
15911591
lifecycle.
15921592

15931593
For more information about Doctrine, see the *Doctrine* section of the
1594-
:doc:`cookbook</cookbook/index>`, which includes the following articles:
1594+
:doc:`cookbook </cookbook/index>`, which includes the following articles:
15951595

15961596
* :doc:`/bundles/DoctrineFixturesBundle/index`
15971597
* :doc:`/cookbook/doctrine/common_extensions`

book/forms.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ corresponding errors printed out with the form.
421421
blank fields.
422422

423423
Validation is a very powerful feature of Symfony2 and has its own
424-
:doc:`dedicated chapter</book/validation>`.
424+
:doc:`dedicated chapter </book/validation>`.
425425

426426
.. index::
427427
single: Forms; Validation groups
@@ -431,19 +431,14 @@ Validation is a very powerful feature of Symfony2 and has its own
431431
Validation Groups
432432
~~~~~~~~~~~~~~~~~
433433

434-
.. tip::
435-
436-
If you're not using :ref:`validation groups <book-validation-validation-groups>`,
437-
then you can skip this section.
438-
439434
If your object takes advantage of :ref:`validation groups <book-validation-validation-groups>`,
440435
you'll need to specify which validation group(s) your form should use::
441436

442437
$form = $this->createFormBuilder($users, array(
443438
'validation_groups' => array('registration'),
444439
))->add(...);
445440

446-
If you're creating :ref:`form classes<book-form-creating-form-classes>` (a
441+
If you're creating :ref:`form classes <book-form-creating-form-classes>` (a
447442
good practice), then you'll need to add the following to the ``setDefaultOptions()``
448443
method::
449444

@@ -596,7 +591,7 @@ Field Type Options
596591

597592
Each field type has a number of options that can be used to configure it.
598593
For example, the ``dueDate`` field is currently being rendered as 3 select
599-
boxes. However, the :doc:`date field</reference/forms/types/date>` can be
594+
boxes. However, the :doc:`date field </reference/forms/types/date>` can be
600595
configured to be rendered as a single text box (where the user would enter
601596
the date as a string in the box)::
602597

@@ -615,7 +610,8 @@ the documentation for each type.
615610
any field. By default, the ``required`` option is set to ``true``, meaning
616611
that HTML5-ready browsers will apply client-side validation if the field
617612
is left blank. If you don't want this behavior, either set the ``required``
618-
option on your field to ``false`` or :ref:`disable HTML5 validation<book-forms-html5-validation-disable>`.
613+
option on your field to ``false`` or
614+
:ref:`disable HTML5 validation <book-forms-html5-validation-disable>`.
619615

620616
Also note that setting the ``required`` option to ``true`` will **not**
621617
result in server-side validation to be applied. In other words, if a
@@ -758,7 +754,7 @@ Take a look at each part:
758754

759755
* ``form_end()`` - Renders the end tag of the form and any fields that have not
760756
yet been rendered. This is useful for rendering hidden fields and taking
761-
advantage of the automatic :ref:`CSRF Protection<forms-csrf>`.
757+
advantage of the automatic :ref:`CSRF Protection <forms-csrf>`.
762758

763759
The majority of the work is done by the ``form_row`` helper, which renders
764760
the label, errors and HTML form widget of each field inside a ``div`` tag
@@ -898,7 +894,7 @@ Twig Template Function Reference
898894
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
899895

900896
If you're using Twig, a full reference of the form rendering functions is
901-
available in the :doc:`reference manual</reference/forms/twig_reference>`.
897+
available in the :doc:`reference manual </reference/forms/twig_reference>`.
902898
Read this to know everything about the helpers available and the options
903899
that can be used with each.
904900

@@ -1073,6 +1069,10 @@ the choice is ultimately up to you.
10731069
The field data can be accessed in a controller with::
10741070

10751071
$form->get('dueDate')->getData();
1072+
1073+
In addition, the data of an unmapped field can also be modified directly::
1074+
1075+
$form->get('dueDate')->setData(new \DateTime());
10761076

10771077
Defining your Forms as Services
10781078
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1161,7 +1161,7 @@ HTML form and then translate user-submitted data back to the original object. As
11611161
such, the topic of persisting the ``Task`` object to the database is entirely
11621162
unrelated to the topic of forms. But, if you've configured the ``Task`` class
11631163
to be persisted via Doctrine (i.e. you've added
1164-
:ref:`mapping metadata<book-doctrine-adding-mapping>` for it), then persisting
1164+
:ref:`mapping metadata <book-doctrine-adding-mapping>` for it), then persisting
11651165
it after a form submission can be done when the form is valid::
11661166
11671167
if ($form->isValid()) {
@@ -1177,7 +1177,7 @@ you can fetch it from the form::
11771177
11781178
$task = $form->getData();
11791179
1180-
For more information, see the :doc:`Doctrine ORM chapter</book/doctrine>`.
1180+
For more information, see the :doc:`Doctrine ORM chapter </book/doctrine>`.
11811181
11821182
The key thing to understand is that when the form is submitted, the submitted
11831183
data is transferred to the underlying object immediately. If you want to
@@ -1340,7 +1340,7 @@ form with many ``Product`` sub-forms). This is done by using the ``collection``
13401340
field type.
13411341
13421342
For more information see the ":doc:`/cookbook/form/form_collections`" cookbook
1343-
entry and the :doc:`collection</reference/forms/types/collection>` field type reference.
1343+
entry and the :doc:`collection </reference/forms/types/collection>` field type reference.
13441344
13451345
.. index::
13461346
single: Forms; Theming
@@ -1523,7 +1523,7 @@ override the default error rendering for *all* fields, copy and customize the
15231523
.. tip::
15241524
15251525
The "parent" type of each field type is available in the
1526-
:doc:`form type reference</reference/forms/types>` for each field type.
1526+
:doc:`form type reference </reference/forms/types>` for each field type.
15271527
15281528
.. index::
15291529
single: Forms; Global Theming
@@ -1813,7 +1813,7 @@ simple array of your submitted data, how can you add constraints to the data of
18131813
your form?
18141814
18151815
The answer is to setup the constraints yourself, and attach them to the individual
1816-
fields. The overall approach is covered a bit more in the :ref:`validation chapter<book-validation-raw-values>`,
1816+
fields. The overall approach is covered a bit more in the :ref:`validation chapter <book-validation-raw-values>`,
18171817
but here's a short example:
18181818
18191819
.. code-block:: php
@@ -1853,12 +1853,12 @@ HTML form so that the user can modify that data. The second goal of a form is to
18531853
take the data submitted by the user and to re-apply it to the object.
18541854
18551855
There's still much more to learn about the powerful world of forms, such as
1856-
how to handle :doc:`file uploads with Doctrine
1857-
</cookbook/doctrine/file_uploads>` or how to create a form where a dynamic
1858-
number of sub-forms can be added (e.g. a todo list where you can keep adding
1859-
more fields via Javascript before submitting). See the cookbook for these
1860-
topics. Also, be sure to lean on the
1861-
:doc:`field type reference documentation</reference/forms/types>`, which
1856+
how to handle
1857+
:doc:`file uploads with Doctrine </cookbook/doctrine/file_uploads>` or how
1858+
to create a form where a dynamic number of sub-forms can be added (e.g. a
1859+
todo list where you can keep adding more fields via Javascript before submitting).
1860+
See the cookbook for these topics. Also, be sure to lean on the
1861+
:doc:`field type reference documentation </reference/forms/types>`, which
18621862
includes examples of how to use each field type and its options.
18631863
18641864
Learn more from the Cookbook

book/from_flat_php_to_symfony2.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ them for you. Here's the same sample application, now built in Symfony2::
582582
}
583583
}
584584

585-
The two controllers are still lightweight. Each uses the :doc:`Doctrine ORM library</book/doctrine>`
585+
The two controllers are still lightweight. Each uses the :doc:`Doctrine ORM library </book/doctrine>`
586586
to retrieve objects from the database and the ``Templating`` component to
587587
render a template and return a ``Response`` object. The list template is
588588
now quite a bit simpler:
@@ -667,7 +667,7 @@ controller method is responsible for returning the final ``Response`` object.
667667
There's really not much else to it.
668668

669669
For a visual representation of how Symfony2 handles each request, see the
670-
:ref:`request flow diagram<request-flow-figure>`.
670+
:ref:`request flow diagram <request-flow-figure>`.
671671

672672
Where Symfony2 Delivers
673673
~~~~~~~~~~~~~~~~~~~~~~~
@@ -681,8 +681,8 @@ migrating the blog from flat PHP to Symfony2 has improved life:
681681
allows for new developers to be productive in your project more quickly;
682682

683683
* 100% of the code you write is for *your* application. You **don't need
684-
to develop or maintain low-level utilities** such as :ref:`autoloading<autoloading-introduction-sidebar>`,
685-
:doc:`routing</book/routing>`, or rendering :doc:`controllers</book/controller>`;
684+
to develop or maintain low-level utilities** such as :ref:`autoloading <autoloading-introduction-sidebar>`,
685+
:doc:`routing </book/routing>`, or rendering :doc:`controllers </book/controller>`;
686686

687687
* Symfony2 gives you **access to open source tools** such as Doctrine and the
688688
Templating, Security, Form, Validation and Translation components (to name
@@ -694,7 +694,7 @@ migrating the blog from flat PHP to Symfony2 has improved life:
694694
* Symfony2's HTTP-centric architecture gives you access to powerful tools
695695
such as **HTTP caching** powered by **Symfony2's internal HTTP cache** or
696696
more powerful tools such as `Varnish`_. This is covered in a later chapter
697-
all about :doc:`caching</book/http_cache>`.
697+
all about :doc:`caching </book/http_cache>`.
698698

699699
And perhaps best of all, by using Symfony2, you now have access to a whole
700700
set of **high-quality open source tools developed by the Symfony2 community**!
@@ -745,7 +745,7 @@ The corresponding ``layout.html.twig`` template is also easier to write:
745745

746746
Twig is well-supported in Symfony2. And while PHP templates will always
747747
be supported in Symfony2, the many advantages of Twig will continue to
748-
be discussed. For more information, see the :doc:`templating chapter</book/templating>`.
748+
be discussed. For more information, see the :doc:`templating chapter </book/templating>`.
749749

750750
Learn more from the Cookbook
751751
----------------------------

book/http_fundamentals.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,12 @@ by adding an entry for ``/contact`` to your routing configuration file:
455455
456456
.. note::
457457

458-
This example uses :doc:`YAML</components/yaml/yaml_format>` to define the routing
458+
This example uses :doc:`YAML </components/yaml/yaml_format>` to define the routing
459459
configuration. Routing configuration can also be written in other formats
460460
such as XML or PHP.
461461

462462
When someone visits the ``/contact`` page, this route is matched, and the
463-
specified controller is executed. As you'll learn in the :doc:`routing chapter</book/routing>`,
463+
specified controller is executed. As you'll learn in the :doc:`routing chapter </book/routing>`,
464464
the ``AcmeDemoBundle:Main:contact`` string is a short syntax that points to a
465465
specific PHP method ``contactAction`` inside a class called ``MainController``::
466466

@@ -479,7 +479,7 @@ specific PHP method ``contactAction`` inside a class called ``MainController``::
479479

480480
In this very simple example, the controller simply creates a
481481
:class:`Symfony\\Component\\HttpFoundation\\Response` object with the HTML
482-
"``<h1>Contact us!</h1>"``. In the :doc:`controller chapter</book/controller>`,
482+
``<h1>Contact us! </h1>``. In the :doc:`controller chapter </book/controller>`,
483483
you'll learn how a controller can render templates, allowing your "presentation"
484484
code (i.e. anything that actually writes out HTML) to live in a separate
485485
template file. This frees up the controller to worry only about the hard
@@ -512,11 +512,11 @@ libraries that can be used inside *any* PHP project. These libraries, called
512512
the *Symfony2 Components*, contain something useful for almost any situation,
513513
regardless of how your project is developed. To name a few:
514514

515-
* :doc:`HttpFoundation</components/http_foundation/introduction>` - Contains
515+
* :doc:`HttpFoundation </components/http_foundation/introduction>` - Contains
516516
the ``Request`` and ``Response`` classes, as well as other classes for handling
517517
sessions and file uploads;
518518

519-
* :doc:`Routing</components/routing/introduction>` - Powerful and fast routing system that
519+
* :doc:`Routing </components/routing/introduction>` - Powerful and fast routing system that
520520
allows you to map a specific URI (e.g. ``/contact``) to some information
521521
about how that request should be handled (e.g. execute the ``contactAction()``
522522
method);
@@ -527,13 +527,13 @@ regardless of how your project is developed. To name a few:
527527
* `Validator`_ A system for creating rules about data and then validating
528528
whether or not user-submitted data follows those rules;
529529

530-
* :doc:`ClassLoader</components/class_loader>` An autoloading library that allows
530+
* :doc:`ClassLoader </components/class_loader/introduction>` An autoloading library that allows
531531
PHP classes to be used without needing to manually ``require`` the files
532532
containing those classes;
533533

534-
* :doc:`Templating</components/templating>` A toolkit for rendering templates,
535-
handling template inheritance (i.e. a template is decorated with a layout)
536-
and performing other common template tasks;
534+
* :doc:`Templating </components/templating/introduction>` A toolkit for rendering
535+
templates, handling template inheritance (i.e. a template is decorated with
536+
a layout) and performing other common template tasks;
537537

538538
* `Security`_ - A powerful library for handling all types of security inside
539539
an application;

0 commit comments

Comments
 (0)