Skip to content

Commit

Permalink
Merge branch '2.4' into 2.5
Browse files Browse the repository at this point in the history
* 2.4:
  Update Collection.rst
  Fixed code highlighting
  Added a note about the lacking features of Yaml Component
  replace "Symfony2" with "Symfony"
  fix name of the Yaml component
  Moved 'contributing' images to their own directory
  add link to form testing chapter in test section

Conflicts:
	components/class_loader/introduction.rst
	quick_tour/the_big_picture.rst
  • Loading branch information
weaverryan committed Sep 15, 2014
2 parents 8f01195 + 3a77561 commit 1018da8
Show file tree
Hide file tree
Showing 118 changed files with 750 additions and 698 deletions.
36 changes: 18 additions & 18 deletions book/controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Controller
==========

A controller is a PHP function you create that takes information from the
HTTP request and constructs and returns an HTTP response (as a Symfony2
HTTP request and constructs and returns an HTTP response (as a Symfony
``Response`` object). The response could be an HTML page, an XML document,
a serialized JSON array, an image, a redirect, a 404 error or anything else
you can dream up. The controller contains whatever arbitrary logic *your
application* needs to render the content of a page.

See how simple this is by looking at a Symfony2 controller in action.
See how simple this is by looking at a Symfony controller in action.
The following controller would render a page that simply prints ``Hello world!``::

use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -50,7 +50,7 @@ common examples:
Requests, Controller, Response Lifecycle
----------------------------------------

Every request handled by a Symfony2 project goes through the same simple lifecycle.
Every request handled by a Symfony project goes through the same simple lifecycle.
The framework takes care of the repetitive tasks and ultimately executes a
controller, which houses your custom application code:

Expand Down Expand Up @@ -87,7 +87,7 @@ A Simple Controller
-------------------

While a controller can be any PHP callable (a function, method on an object,
or a ``Closure``), in Symfony2, a controller is usually a single method inside
or a ``Closure``), in Symfony, a controller is usually a single method inside
a controller object. Controllers are also called *actions*.

.. code-block:: php
Expand Down Expand Up @@ -117,7 +117,7 @@ a controller object. Controllers are also called *actions*.

This controller is pretty straightforward:

* *line 4*: Symfony2 takes advantage of PHP 5.3 namespace functionality to
* *line 4*: Symfony takes advantage of PHP 5.3 namespace functionality to
namespace the entire controller class. The ``use`` keyword imports the
``Response`` class, which the controller must return.

Expand Down Expand Up @@ -185,8 +185,8 @@ controller and passes in ``ryan`` for the ``$name`` variable. Creating a
"page" means simply creating a controller method and associated route.

Notice the syntax used to refer to the controller: ``AcmeHelloBundle:Hello:index``.
Symfony2 uses a flexible string notation to refer to different controllers.
This is the most common syntax and tells Symfony2 to look for a controller
Symfony uses a flexible string notation to refer to different controllers.
This is the most common syntax and tells Symfony to look for a controller
class called ``HelloController`` inside a bundle named ``AcmeHelloBundle``. The
method ``indexAction()`` is then executed.

Expand Down Expand Up @@ -232,7 +232,7 @@ passed to that method::

The controller has a single argument, ``$name``, which corresponds to the
``{name}`` parameter from the matched route (``ryan`` in the example). In
fact, when executing your controller, Symfony2 matches each argument of
fact, when executing your controller, Symfony matches each argument of
the controller with a parameter from the matched route. Take the following
example:

Expand Down Expand Up @@ -369,7 +369,7 @@ Use it! See :doc:`/cookbook/templating/render_without_controller`.
The Base Controller Class
-------------------------

For convenience, Symfony2 comes with a base ``Controller`` class that assists
For convenience, Symfony comes with a base ``Controller`` class that assists
with some of the most common controller tasks and gives your controller class
access to any resource it might need. By extending this ``Controller`` class,
you can take advantage of several helper methods.
Expand All @@ -393,7 +393,7 @@ Add the ``use`` statement atop the ``Controller`` class and then modify the

This doesn't actually change anything about how your controller works. In
the next section, you'll learn about the helper methods that the base controller
class makes available. These methods are just shortcuts to using core Symfony2
class makes available. These methods are just shortcuts to using core Symfony
functionality that's available to you with or without the use of the base
``Controller`` class. A great way to see the core functionality in action
is to look in the
Expand Down Expand Up @@ -427,7 +427,7 @@ Common Controller Tasks
Though a controller can do virtually anything, most controllers will perform
the same basic tasks over and over again. These tasks, such as redirecting,
forwarding, rendering templates and accessing core services, are very easy
to manage in Symfony2.
to manage in Symfony.

.. index::
single: Controller; Redirecting
Expand Down Expand Up @@ -501,15 +501,15 @@ look something like the following::
}

And just like when creating a controller for a route, the order of the arguments
to ``fancyAction`` doesn't matter. Symfony2 matches the index key names
to ``fancyAction`` doesn't matter. Symfony matches the index key names
(e.g. ``name``) with the method argument names (e.g. ``$name``). If you
change the order of the arguments, Symfony2 will still pass the correct
change the order of the arguments, Symfony will still pass the correct
value to each variable.

.. tip::

Like other base ``Controller`` methods, the ``forward`` method is just
a shortcut for core Symfony2 functionality. A forward can be accomplished
a shortcut for core Symfony functionality. A forward can be accomplished
directly by duplicating the current request. When this
:ref:`sub request <http-kernel-sub-requests>` is executed via the ``http_kernel``
service the ``HttpKernel`` returns a ``Response`` object::
Expand Down Expand Up @@ -603,7 +603,7 @@ The Symfony templating engine is explained in great detail in the
Accessing other Services
~~~~~~~~~~~~~~~~~~~~~~~~

When extending the base controller class, you can access any Symfony2 service
When extending the base controller class, you can access any Symfony service
via the ``get()`` method. Here are several common services you might need::

$templating = $this->get('templating');
Expand Down Expand Up @@ -648,7 +648,7 @@ The ``createNotFoundException()`` method creates a special ``NotFoundHttpExcepti
object, which ultimately triggers a 404 HTTP response inside Symfony.

Of course, you're free to throw any ``Exception`` class in your controller -
Symfony2 will automatically return a 500 HTTP response code.
Symfony will automatically return a 500 HTTP response code.

.. code-block:: php
Expand All @@ -666,9 +666,9 @@ Both of these error pages can be customized. For details, read the
Managing the Session
--------------------

Symfony2 provides a nice session object that you can use to store information
Symfony provides a nice session object that you can use to store information
about the user (be it a real person using a browser, a bot, or a web service)
between requests. By default, Symfony2 stores the attributes in a cookie
between requests. By default, Symfony stores the attributes in a cookie
by using the native PHP sessions.

Storing and retrieving information from the session can be easily achieved
Expand Down
2 changes: 1 addition & 1 deletion book/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ for you:
.. sidebar:: Setting up the Database to be UTF8

One mistake even seasoned developers make when starting a Symfony2 project
One mistake even seasoned developers make when starting a Symfony project
is forgetting to setup default charset and collation on their database,
ending up with latin type collations, which are default for most databases.
They might even remember to do it the very first time, but forget that
Expand Down
20 changes: 10 additions & 10 deletions book/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ Forms
=====

Dealing with HTML forms is one of the most common - and challenging - tasks for
a web developer. Symfony2 integrates a Form component that makes dealing with
a web developer. Symfony integrates a Form component that makes dealing with
forms easy. In this chapter, you'll build a complex form from the ground-up,
learning the most important features of the form library along the way.

.. note::

The Symfony Form component is a standalone library that can be used outside
of Symfony2 projects. For more information, see the `Symfony2 Form component`_
of Symfony projects. For more information, see the `Symfony Form component`_
on GitHub.

.. index::
Expand Down Expand Up @@ -80,7 +80,7 @@ Building the Form
~~~~~~~~~~~~~~~~~

Now that you've created a ``Task`` class, the next step is to create and
render the actual HTML form. In Symfony2, this is done by building a form
render the actual HTML form. In Symfony, this is done by building a form
object and then rendering it in a template. For now, this can all be done
from inside a controller::

Expand Down Expand Up @@ -119,7 +119,7 @@ from inside a controller::
how to build your form in a standalone class, which is recommended as
your form becomes reusable.

Creating a form requires relatively little code because Symfony2 form objects
Creating a form requires relatively little code because Symfony form objects
are built with a "form builder". The form builder's purpose is to allow you
to write simple form "recipes", and have it do all the heavy-lifting of actually
building the form.
Expand All @@ -136,7 +136,7 @@ the server.
Support for submit buttons was introduced in Symfony 2.3. Before that, you had
to add buttons to the form's HTML manually.

Symfony2 comes with many built-in types that will be discussed shortly
Symfony comes with many built-in types that will be discussed shortly
(see :ref:`book-forms-type-reference`).

.. index::
Expand Down Expand Up @@ -318,7 +318,7 @@ Form Validation
---------------

In the previous section, you learned how a form can be submitted with valid
or invalid data. In Symfony2, validation is applied to the underlying object
or invalid data. In Symfony, validation is applied to the underlying object
(e.g. ``Task``). In other words, the question isn't whether the "form" is
valid, but whether or not the ``$task`` object is valid after the form has
applied the submitted data to it. Calling ``$form->isValid()`` is a shortcut
Expand Down Expand Up @@ -441,7 +441,7 @@ corresponding errors printed out with the form.
'attr' => array('novalidate' => 'novalidate'),
)) ?>

Validation is a very powerful feature of Symfony2 and has its own
Validation is a very powerful feature of Symfony and has its own
:doc:`dedicated chapter </book/validation>`.

.. index::
Expand Down Expand Up @@ -982,9 +982,9 @@ to the ``form()`` or the ``form_start()`` helper:

.. note::

If the form's method is not GET or POST, but PUT, PATCH or DELETE, Symfony2
If the form's method is not GET or POST, but PUT, PATCH or DELETE, Symfony
will insert a hidden field with the name ``_method`` that stores this method.
The form will be submitted in a normal POST request, but Symfony2's router
The form will be submitted in a normal POST request, but Symfony's router
is capable of detecting the ``_method`` parameter and will interpret it as
a PUT, PATCH or DELETE request. Read the cookbook chapter
":doc:`/cookbook/routing/method_parameters`" for more information.
Expand Down Expand Up @@ -1901,7 +1901,7 @@ Learn more from the Cookbook
* :doc:`/cookbook/form/dynamic_form_modification`
* :doc:`/cookbook/form/data_transformers`

.. _`Symfony2 Form component`: https://github.com/symfony/Form
.. _`Symfony Form component`: https://github.com/symfony/Form
.. _`DateTime`: http://php.net/manual/en/class.datetime.php
.. _`Twig Bridge`: https://github.com/symfony/symfony/tree/master/src/Symfony/Bridge/Twig
.. _`form_div_layout.html.twig`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
Expand Down
Loading

0 comments on commit 1018da8

Please sign in to comment.