Permalink
Browse files

Merge branch '2.1'

  • Loading branch information...
2 parents 19f2fdc + 40c83db commit d1bcc4ef8d55adb40038a95b377d2cf3d8980184 @weaverryan weaverryan committed Nov 23, 2012
Showing with 216 additions and 122 deletions.
  1. +2 −2 book/controller.rst
  2. +3 −3 book/doctrine.rst
  3. +4 −4 book/forms.rst
  4. +2 −2 book/from_flat_php_to_symfony2.rst
  5. +7 −1 book/installation.rst
  6. +3 −3 book/service_container.rst
  7. +6 −4 book/testing.rst
  8. +2 −2 book/translation.rst
  9. +1 −1 components/config/definition.rst
  10. +13 −1 components/console/introduction.rst
  11. +1 −1 components/dependency_injection/advanced.rst
  12. +1 −1 components/dependency_injection/definitions.rst
  13. +2 −2 components/dom_crawler.rst
  14. +1 −1 components/filesystem.rst
  15. +1 −1 components/http_foundation/introduction.rst
  16. +1 −1 components/http_foundation/session_configuration.rst
  17. +3 −3 components/http_foundation/sessions.rst
  18. +1 −1 components/yaml.rst
  19. +3 −3 contributing/code/conventions.rst
  20. +1 −1 contributing/code/patches.rst
  21. +17 −14 contributing/documentation/overview.rst
  22. +2 −2 cookbook/configuration/external_parameters.rst
  23. +2 −2 cookbook/configuration/override_dir_structure.rst
  24. +22 −0 cookbook/configuration/pdo_session_storage.rst
  25. +4 −4 cookbook/console/console_command.rst
  26. +3 −0 cookbook/console/generating_urls.rst
  27. +1 −1 cookbook/doctrine/file_uploads.rst
  28. +1 −1 cookbook/event_dispatcher/before_after_filters.rst
  29. +2 −2 cookbook/form/create_custom_field_type.rst
  30. +17 −0 cookbook/form/data_transformers.rst
  31. +2 −2 cookbook/form/dynamic_form_generation.rst
  32. +1 −1 cookbook/logging/monolog_email.rst
  33. +1 −1 cookbook/routing/slash_in_parameter.rst
  34. +4 −4 cookbook/security/entity_provider.rst
  35. +1 −1 cookbook/service_container/event_listener.rst
  36. +1 −1 cookbook/service_container/scopes.rst
  37. +13 −1 cookbook/testing/doctrine.rst
  38. +1 −1 cookbook/workflow/new_project_svn.rst
  39. +4 −4 quick_tour/the_architecture.rst
  40. +22 −5 quick_tour/the_big_picture.rst
  41. +8 −8 quick_tour/the_controller.rst
  42. +2 −2 quick_tour/the_view.rst
  43. +2 −2 reference/configuration/doctrine.rst
  44. +2 −2 reference/configuration/framework.rst
  45. +10 −10 reference/constraints/Valid.rst
  46. +10 −10 reference/forms/types/collection.rst
  47. +3 −3 reference/forms/types/options/by_reference.rst.inc
View
4 book/controller.rst
@@ -11,7 +11,7 @@ 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.
-To see how simple this is, let's look at a Symfony2 controller in action.
+See how simple this is by looking at a Symfony2 controller in action.
The following controller would render a page that simply prints ``Hello world!``::
use Symfony\Component\HttpFoundation\Response;
@@ -115,7 +115,7 @@ a controller object. Controllers are also called *actions*.
will house several controllers/actions (e.g. ``updateAction``, ``deleteAction``,
etc).
-This controller is pretty straightforward, but let's walk through it:
+This controller is pretty straightforward:
* *line 4*: Symfony2 takes advantage of PHP 5.3 namespace functionality to
namespace the entire controller class. The ``use`` keyword imports the
View
6 book/doctrine.rst
@@ -4,7 +4,7 @@
Databases and Doctrine
======================
-Let's face it, one of the most common and challenging tasks for any application
+One of the most common and challenging tasks for any application
involves persisting and reading information to and from a database. Fortunately,
Symfony comes integrated with `Doctrine`_, a library whose sole goal is to
give you powerful tools to make this easy. In this chapter, you'll learn the
@@ -420,7 +420,7 @@ of the bundle:
If you're following along with this example, you'll need to create a
route that points to this action to see it work.
-Let's walk through this example:
+Take a look at the previous example in more detail:
* **lines 9-12** In this section, you instantiate and work with the ``$product``
object like any other, normal PHP object.
@@ -965,7 +965,7 @@ table, and ``product.category_id`` column, and new foreign key:
Saving Related Entities
~~~~~~~~~~~~~~~~~~~~~~~
-Now, let's see the code in action. Imagine you're inside a controller::
+Now you can see this new code in action! Imagine you're inside a controller::
// ...
View
8 book/forms.rst
@@ -573,7 +573,7 @@ the correct values of a number of field options.
* ``max_length``: If the field is some sort of text field, then the ``max_length``
option can be guessed from the validation constraints (if ``Length`` or
``Range`` is used) or from the Doctrine metadata (via the field's length).
-
+
.. note::
These field options are *only* guessed if you're using Symfony to guess
@@ -625,7 +625,7 @@ of code. Of course, you'll usually need much more flexibility when rendering:
<input type="submit" />
</form>
-Let's take a look at each part:
+Take a look at each part:
* ``form_enctype(form)`` - If at least one field is a file upload field, this
renders the obligatory ``enctype="multipart/form-data"``;
@@ -1096,7 +1096,7 @@ In PHP, each form "fragment" is rendered via an individual template file.
To customize any part of how a form renders, you just need to override the
existing template by creating a new one.
-To understand how this works, let's customize the ``form_row`` fragment and
+To understand how this works, customize the ``form_row`` fragment and
add a class attribute to the ``div`` element that surrounds each row. To
do this, create a new template file that will store the new markup:
@@ -1340,7 +1340,7 @@ to define form output.
ever be needed in a single template.
.. caution::
-
+
This ``{% form_theme form _self %}`` functionality will *only* work
if your template extends another. If your template does not, you
must point ``form_theme`` to a separate template.
View
4 book/from_flat_php_to_symfony2.rst
@@ -426,7 +426,7 @@ an autoloader that Symfony provides. An autoloader is a tool that makes it
possible to start using PHP classes without explicitly including the file
containing the class.
-First, `download symfony`_ and place it into a ``vendor/symfony/symfony/`` directory.
+First, `download Symfony`_ and place it into a ``vendor/symfony/symfony/`` directory.
Next, create an ``app/bootstrap.php`` file. Use it to ``require`` the two
files in the application and to configure the autoloader:
@@ -740,7 +740,7 @@ Learn more from the Cookbook
* :doc:`/cookbook/controller/service`
.. _`Doctrine`: http://www.doctrine-project.org
-.. _`download symfony`: http://symfony.com/download
+.. _`download Symfony`: http://symfony.com/download
.. _`Routing`: https://github.com/symfony/Routing
.. _`Templating`: https://github.com/symfony/Templating
.. _`KnpBundles.com`: http://knpbundles.com/
View
8 book/installation.rst
@@ -67,6 +67,12 @@ Distribution:
For an exact version, replace `dev-master` with the latest Symfony version
(e.g. 2.1.1). For details, see the `Symfony Installation Page`_
+.. tip::
+
+ To download the vendor files faster and without unnecessary directories
+ (e.g. "Tests"), add the ``--prefer-dist`` option at the end of any Composer
+ command.
+
This command may take several minutes to run as Composer download the Standard
Distribution along with all of the vendor libraries that it needs. When it finishes,
you should have a directory that looks something like this:
@@ -279,7 +285,7 @@ development! Your distribution may contain some sample code - check the
to learn about what sample code was included with your distribution and how
you can remove it later.
-If you're new to Symfony, join us in the ":doc:`page_creation`", where you'll
+If you're new to Symfony, check out ":doc:`page_creation`", where you'll
learn how to create pages, change configuration, and do everything else you'll
need in your new application.
View
6 book/service_container.rst
@@ -79,7 +79,7 @@ you need it::
$mailer = new Mailer('sendmail');
$mailer->send('ryan@foobar.net', ...);
-This is easy enough. The imaginary ``Mailer`` class allows us to configure
+This is easy enough. The imaginary ``Mailer`` class allows you to configure
the method used to deliver the email messages (e.g. ``sendmail``, ``smtp``, etc).
But what if you wanted to use the mailer service somewhere else? You certainly
don't want to repeat the mailer configuration *every* time you need to use
@@ -312,7 +312,7 @@ Importing other Container Configuration Resources
.. tip::
In this section, service configuration files are referred to as *resources*.
- This is to highlight that fact that, while most configuration resources
+ This is to highlight the fact that, while most configuration resources
will be files (e.g. YAML, XML, PHP), Symfony2 is so flexible that configuration
could be loaded from anywhere (e.g. a database or even via an external
web service).
@@ -576,7 +576,7 @@ This approach is fine, but what if you decide later that the ``NewsletterManager
class needs a second or third constructor argument? What if you decide to
refactor our code and rename the class? In both cases, you'd need to find every
place where the ``NewsletterManager`` is instantiated and modify it. Of course,
-the service container gives us a much more appealing option:
+the service container gives you a much more appealing option:
.. configuration-block::
View
10 book/testing.rst
@@ -236,17 +236,19 @@ document::
)
The ``server`` array is the raw values that you'd expect to normally
- find in the PHP `$_SERVER`_ superglobal. For example, to set the `Content-Type`
- and `Referer` HTTP headers, you'd pass the following::
+ find in the PHP `$_SERVER`_ superglobal. For example, to set the `Content-Type`,
+ `Referer` and `X-Requested-With' HTTP headers, you'd pass the following (mind
+ the `HTTP_` prefix for non standard headers)::
$client->request(
'GET',
'/demo/hello/Fabien',
array(),
array(),
array(
- 'CONTENT_TYPE' => 'application/json',
- 'HTTP_REFERER' => '/foo/bar',
+ 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_REFERER' => '/foo/bar',
+ 'HTTP_X-Requested-With' => 'XMLHttpRequest',
)
);
View
4 book/translation.rst
@@ -831,15 +831,15 @@ locale to use for translation::
'Symfony2 is great',
array(),
'messages',
- 'fr_FR',
+ 'fr_FR'
);
$this->get('translator')->transChoice(
'{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples',
10,
array('%count%' => 10),
'messages',
- 'fr_FR',
+ 'fr_FR'
);
Translating Database Content
View
2 components/config/definition.rst
@@ -440,7 +440,7 @@ By changing a string value into an associative array with ``name`` as the key::
->ifString()
->then(function($v) { return array('name'=> $v); })
->end()
- ->scalarValue('name')->isRequired()
+ ->scalarNode('name')->isRequired()
// ...
->end()
;
View
14 components/console/introduction.rst
@@ -23,7 +23,7 @@ You can install the component in many different ways:
Creating a basic Command
------------------------
-To make a console command to greet us from the command line, create ``GreetCommand.php``
+To make a console command that greets you from the command line, create ``GreetCommand.php``
and add the following to it::
namespace Acme\DemoBundle\Command;
@@ -138,6 +138,18 @@ Available foreground and background colors are: ``black``, ``red``, ``green``,
And available options are: ``bold``, ``underscore``, ``blink``, ``reverse`` and ``conceal``.
+You can also set these colors and options inside the tagname::
+
+ // green text
+ $output->writeln('<fg=green>foo</fg=green>');
+
+ // black text on a cyan background
+ $output->writeln('<fg=black;bg=cyan>foo</fg=black;bg=cyan>');
+
+ // bold text on a yellow background
+ $output->writeln('<bg=yellow;options=bold>foo</bg=yellow;options=bold>');
+
+
Using Command Arguments
-----------------------
View
2 components/dependency_injection/advanced.rst
@@ -121,5 +121,5 @@ the service itself gets loaded. To do so, you can use the ``file`` directive.
$definition->setFile('%kernel.root_dir%/src/path/to/file/foo.php');
$container->setDefinition('foo', $definition);
-Notice that symfony will internally call the PHP function require_once
+Notice that Symfony will internally call the PHP function require_once
which means that your file will be included only once per request.
View
2 components/dependency_injection/definitions.rst
@@ -91,7 +91,7 @@ You can add a new argument to the end of the arguments array using::
$definition->addArgument($argument);
-The argument can be a string, an array, a service parameter by using ``%paramater_name%``
+The argument can be a string, an array, a service parameter by using ``%parameter_name%``
or a service id by using ::
use Symfony\Component\DependencyInjection\Reference;
View
4 components/dom_crawler.rst
@@ -179,7 +179,7 @@ Links
To find a link by name (or a clickable image by its ``alt`` attribute), use
the ``selectLink`` method on an existing crawler. This returns a Crawler
-instance with just the selected link(s). Calling ``link()`` gives us a special
+instance with just the selected link(s). Calling ``link()`` gives you a special
:class:`Symfony\\Component\\DomCrawler\\Link` object::
$linksCrawler = $crawler->selectLink('Go elsewhere...');
@@ -319,4 +319,4 @@ directly::
$crawler = $client->submit($form);
.. _`Goutte`: https://github.com/fabpot/goutte
-.. _Packagist: https://packagist.org/packages/symfony/dom-crawler
+.. _Packagist: https://packagist.org/packages/symfony/dom-crawler
View
2 components/filesystem.rst
@@ -33,7 +33,7 @@ endpoint for filesystem operations::
try {
$fs->mkdir('/tmp/random/dir/' . mt_rand());
} catch (IOException $e) {
- echo "An error occured while creating your directory";
+ echo "An error occurred while creating your directory";
}
.. note::
View
2 components/http_foundation/introduction.rst
@@ -227,7 +227,7 @@ by using the following methods:
returns the list of accepted languages ordered by descending quality;
* :method:`Symfony\\Component\\HttpFoundation\\Request::getCharsets`:
- returns the list of accepted languages ordered by descending quality;
+ returns the list of accepted charsets ordered by descending quality;
.. versionadded:: 2.2
The :class:`Symfony\\Component\\HttpFoundation\\AcceptHeader` class is new in Symfony 2.2.
View
2 components/http_foundation/session_configuration.rst
@@ -204,7 +204,7 @@ Both methods return a Unix timestamp (relative to the server).
This meta-data can be used to explicitly expire a session on access, e.g.::
$session->start();
- if (time() - $session->getMetadataBag()->getLastUpdate() > $maxIdleTime) {
+ if (time() - $session->getMetadataBag()->getLastUsed() > $maxIdleTime) {
$session->invalidate();
throw new SessionExpired(); // redirect to expired session page
}
View
6 components/http_foundation/sessions.rst
@@ -37,7 +37,7 @@ Quick example::
.. note::
- Symfony sessions are designed to replace several native PHP funtions.
+ Symfony sessions are designed to replace several native PHP functions.
Applications should avoid using ``session_start()``, ``session_regenerate_id()``,
``session_id()``, ``session_name()``, and ``session_destroy()`` and instead
use the APIs in the following section.
@@ -131,7 +131,7 @@ an array. A few methods exist for "Bag" management:
Session meta-data
* :method:`Symfony\\Component\\HttpFoundation\\Session\\Session::getMetadataBag`:
- Gets the :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\MetadataBag`
+ Gets the :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\MetadataBag`
which contains information about the session.
@@ -239,7 +239,7 @@ Flash messages
~~~~~~~~~~~~~~
The purpose of the :class:`Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface`
-is to provide a way of settings and retrieving messages on a per session basis.
+is to provide a way of setting and retrieving messages on a per session basis.
The usual workflow for flash messages would be set in an request, and displayed
after a page redirect. For example, a user submits a form which hits an update
controller, and after processing the controller redirects the page to either the
View
2 components/yaml.rst
@@ -122,7 +122,7 @@ When loading a YAML file, it is sometimes better to use the
use Symfony\Component\Yaml\Yaml;
- $loader = Yaml::parse('/path/to/file.yml');
+ $yaml = Yaml::parse('/path/to/file.yml');
The :method:`Symfony\\Component\\Yaml\\Yaml::parse` static method takes a YAML
string or a file containing YAML. Internally, it calls the
View
6 contributing/code/conventions.rst
@@ -32,7 +32,7 @@ is a main relation:
* a ``CookieJar`` has many ``Cookie`` objects;
* a Service ``Container`` has many services and many parameters (as services
- is the main relation, we use the naming convention for this relation);
+ is the main relation, the naming convention is used for this relation);
* a Console ``Input`` has many arguments and many options. There is no "main"
relation, and so the naming convention does not apply.
@@ -72,7 +72,7 @@ must be used instead (where ``XXX`` is the name of the related thing):
.. note::
- While "setXXX" and "replaceXXX" are very similar, there is one notable
- difference: "setXXX" may replace, or add new elements to the relation.
+ While "setXXX" and "replaceXXX" are very similar, there is one notable
+ difference: "setXXX" may replace, or add new elements to the relation.
"replaceXXX", on the other hand, cannot add new elements. If an unrecognized
key as passed to "replaceXXX" it must throw an exception.
View
2 contributing/code/patches.rst
@@ -29,7 +29,7 @@ Set up your user information with your real name and a working email address:
.. tip::
- If you are new to Git, we highly recommend you to read the excellent and
+ If you are new to Git, you are highly recommended to read the excellent and
free `ProGit`_ book.
.. tip::
View
31 contributing/documentation/overview.rst
@@ -26,12 +26,12 @@ then clone your fork:
$ git clone git://github.com/YOURUSERNAME/symfony-docs.git
Consistent with Symfony's source code, the documentation repository is split into
-three branches: ``2.0`` for the current Symfony 2.0.x release, ``2.1`` for the
-current Symfony 2.1.x release and ``master`` as the development branch for
+three branches: ``2.0`` for the current Symfony 2.0.x release, ``2.1`` for the
+current Symfony 2.1.x release and ``master`` as the development branch for
upcoming releases.
Unless you're documenting a feature that's new to Symfony 2.1, your changes
-should always be based on the 2.0 branch instead of the master branch. To do
+should always be based on the 2.0 branch instead of the master branch. To do
this checkout the 2.0 branch before the next step:
.. code-block:: bash
@@ -52,7 +52,7 @@ the ``symfony-docs`` ``master`` branch.
.. image:: /images/docs-pull-request.png
:align: center
-If you have made your changes based on the 2.0 branch then you need to change
+If you have made your changes based on the 2.0 branch then you need to change
the base branch to be 2.0 on the preview page:
.. image:: /images/docs-pull-request-change-base.png
@@ -61,7 +61,7 @@ the base branch to be 2.0 on the preview page:
.. note::
All changes made to the 2.0 branch will be merged into 2.1 which in turn will be
- merged into the master branch for the next release on a weekly basis.
+ merged into the master branch for the next release on a weekly basis.
GitHub covers the topic of `pull requests`_ in detail.
@@ -73,9 +73,9 @@ GitHub covers the topic of `pull requests`_ in detail.
.. tip::
Please be patient. It can take from 15 minutes to several days for your changes
- to appear on the symfony.com website after the documentation team merges your
- pull request. You can check if your changes have introduced some markup issues
- by going to the `Documentation Build Errors`_ page (it is updated each French
+ to appear on the symfony.com website after the documentation team merges your
+ pull request. You can check if your changes have introduced some markup issues
+ by going to the `Documentation Build Errors`_ page (it is updated each French
night at 3AM when the server rebuilds the documentation).
Standards
@@ -88,20 +88,23 @@ look and feel familiar, you should follow these rules:
as well as the `Twig Coding Standards`_;
* Each line should break approximately after the first word that crosses the
72nd character (so most lines end up being 72-78 lines);
-* When we fold one or more lines of code, we place ``...`` in a comment at the point
+* To avoid horizontal scrolling on code blocks, we prefer to break a line
+ correctly if it crosses the 85th character;
+* When you fold one or more lines of code, place ``...`` in a comment at the point
of the fold. These comments are: ``// ...`` (php), ``# ...`` (yaml/bash), ``{# ... #}``
(twig), ``<!-- ... -->`` (xml/html), ``; ...`` (ini), ``...`` (text);
-* When we fold a part of a line, e.g. a variable value, we put ``...`` (without comment)
+* When you fold a part of a line, e.g. a variable value, put ``...`` (without comment)
at the place of the fold;
* Description of the folded code: (optional)
- If we fold several lines: the description of the fold can be placed after the ``...``
- If we fold only part of a line: the description can be placed before the line;
+ If you fold several lines: the description of the fold can be placed after the ``...``
+ If you fold only part of a line: the description can be placed before the line;
* If useful, a ``codeblock`` should begin with a comment containing the filename
of the file in the code block. Don't place a blank line after this comment,
unless the next line is also a comment;
* You should put a ``$`` in front of every bash line;
-* We prefer the ``::`` shorthand over ``.. code-block:: php`` to begin a PHP
- code block.
+* The ``::`` shorthand is preferred over ``.. code-block:: php`` to begin a PHP
+ code block;
+* You should use a form of *you* instead of *we*.
An example::
View
4 cookbook/configuration/external_parameters.rst
@@ -7,7 +7,7 @@ How to Set External Parameters in the Service Container
In the chapter :doc:`/cookbook/configuration/environments`, you learned how
to manage your application configuration. At times, it may benefit your application
to store certain credentials outside of your project code. Database configuration
-is one such example. The flexibility of the symfony service container allows
+is one such example. The flexibility of the Symfony service container allows
you to easily do this.
Environment Variables
@@ -158,7 +158,7 @@ in the container. The following imports a file named ``parameters.php``.
In ``parameters.php``, tell the service container the parameters that you wish
to set. This is useful when important configuration is in a nonstandard
format. The example below includes a Drupal database's configuration in
-the symfony service container.
+the Symfony service container.
.. code-block:: php
View
4 cookbook/configuration/override_dir_structure.rst
@@ -38,7 +38,7 @@ in the ``AppKernel`` class of you application::
public function getCacheDir()
{
- return $this->rootDir.'/'.$this->environment.'/cache/';
+ return $this->rootDir.'/'.$this->environment.'/cache';
}
}
@@ -69,7 +69,7 @@ method::
public function getLogDir()
{
- return $this->rootDir.'/'.$this->environment.'/logs/';
+ return $this->rootDir.'/'.$this->environment.'/logs';
}
}
View
22 cookbook/configuration/pdo_session_storage.rst
@@ -187,3 +187,25 @@ For PostgreSQL, the statement should look like this:
session_time integer NOT NULL,
CONSTRAINT session_pkey PRIMARY KEY (session_id)
);
+
+Microsoft SQL Server
+~~~~~~~~~~~~~~~~~~~~
+
+For MSSQL, the statement might look like the following:
+
+.. code-block:: sql
+
+ CREATE TABLE [dbo].[session](
+ [session_id] [nvarchar](255) NOT NULL,
+ [session_value] [ntext] NOT NULL,
+ [session_time] [int] NOT NULL,
+ PRIMARY KEY CLUSTERED(
+ [session_id] ASC
+ ) WITH (
+ PAD_INDEX = OFF,
+ STATISTICS_NORECOMPUTE = OFF,
+ IGNORE_DUP_KEY = OFF,
+ ALLOW_ROW_LOCKS = ON,
+ ALLOW_PAGE_LOCKS = ON
+ ) ON [PRIMARY]
+ ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
View
8 cookbook/console/console_command.rst
@@ -15,7 +15,7 @@ To make the console commands available automatically with Symfony2, create a
``Command`` directory inside your bundle and create a php file suffixed with
``Command.php`` for each command that you want to provide. For example, if you
want to extend the ``AcmeDemoBundle`` (available in the Symfony Standard
-Edition) to greet us from the command line, create ``GreetCommand.php`` and
+Edition) to greet you from the command line, create ``GreetCommand.php`` and
add the following to it::
// src/Acme/DemoBundle/Command/GreetCommand.php
@@ -93,9 +93,9 @@ should be used instead of :class:`Symfony\\Component\\Console\\Application`::
Getting Services from the Service Container
-------------------------------------------
-By using :class:`Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand`
-as the base class for the command (instead of the more basic
-:class:`Symfony\\Component\\Console\\Command\\Command`), you have access to the
+By using :class:`Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand`
+as the base class for the command (instead of the more basic
+:class:`Symfony\\Component\\Console\\Command\\Command`), you have access to the
service container. In other words, you have access to any configured service.
For example, you could easily extend the task to be translatable::
View
3 cookbook/console/generating_urls.rst
@@ -19,6 +19,9 @@ and per Command.
Configuring the Request Context globally
----------------------------------------
+.. versionadded:: 2.1
+ The host and scheme parameters are available since Symfony 2.1
+
To configure the Request Context - which is used by the URL Generator - you can
redefine the parameters it uses as default values to change the default host
(localhost) and scheme (http). Note that this does not impact URLs generated
View
2 cookbook/doctrine/file_uploads.rst
@@ -216,7 +216,7 @@ object, which is what's returned after a ``file`` field is submitted::
// move takes the target directory and then the target filename to move to
$this->file->move($this->getUploadRootDir(), $this->file->getClientOriginalName());
- // set the path property to the filename where you'ved saved the file
+ // set the path property to the filename where you've saved the file
$this->path = $this->file->getClientOriginalName();
// clean up the file property as you won't need it anymore
View
2 cookbook/event_dispatcher/before_after_filters.rst
@@ -180,7 +180,7 @@ your listener to be called just before any controller is executed.
With this configuration, your ``TokenListener`` ``onKernelController`` method
will be executed on each request. If the controller that is about to be executed
implements ``TokenAuthenticatedController``, token authentication is
-applied. This lets us have a "before" filter on any controller that you
+applied. This lets you have a "before" filter on any controller that you
want.
After filters with the ``kernel.response`` Event
View
4 cookbook/form/create_custom_field_type.rst
@@ -204,7 +204,7 @@ the ``genders`` parameter value as the first argument to its to-be-created
# src/Acme/DemoBundle/Resources/config/services.yml
services:
- form.type.gender:
+ acme_demo.form.type.gender:
class: Acme\DemoBundle\Form\Type\GenderType
arguments:
- "%genders%"
@@ -214,7 +214,7 @@ the ``genders`` parameter value as the first argument to its to-be-created
.. code-block:: xml
<!-- src/Acme/DemoBundle/Resources/config/services.xml -->
- <service id="form.type.gender" class="Acme\DemoBundle\Form\Type\GenderType">
+ <service id="acme_demo.form.type.gender" class="Acme\DemoBundle\Form\Type\GenderType">
<argument>%genders%</argument>
<tag name="form.type" alias="gender" />
</service>
View
17 cookbook/form/data_transformers.rst
@@ -125,6 +125,23 @@ issue field in some form.
);
}
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
+ {
+ $resolver->setDefaults(array(
+ 'data_class' => 'Acme\TaskBundle\Entity\Task',
+ ));
+
+ $resolver->setRequired(array(
+ 'em',
+ ));
+
+ $resolver->setAllowedTypes(array(
+ 'em' => 'Doctrine\Common\Persistence\ObjectManager',
+ ));
+
+ // ...
+ }
+
// ...
}
View
4 cookbook/form/dynamic_form_generation.rst
@@ -35,7 +35,7 @@ of what a bare form class looks like::
Let's assume for a moment that this form utilizes an imaginary "Product" class
that has only two relevant properties ("name" and "price"). The form generated
-from this class will look the exact same regardless of a new Product is being created
+from this class will look the exact same regardless if a new Product is being created
or if an existing product is being edited (e.g. a product fetched from the database).
Suppose now, that you don't want the user to be able to change the ``name`` value
@@ -120,7 +120,7 @@ might look like the following::
// During form creation setData() is called with null as an argument
// by the FormBuilder constructor. You're only concerned with when
// setData is called with an actual Entity object in it (whether new
- // or fetched with Doctrine). This if statement lets us skip right
+ // or fetched with Doctrine). This if statement lets you skip right
// over the null condition.
if (null === $data) {
return;
View
2 cookbook/logging/monolog_email.rst
@@ -1,5 +1,5 @@
.. index::
- single: Logging; Emailling errors
+ single: Logging; Emailing errors
How to Configure Monolog to Email Errors
========================================
View
2 cookbook/routing/slash_in_parameter.rst
@@ -15,7 +15,7 @@ matches the ``/hello/{name}`` route, where ``{name}`` equals ``Fabien/Kris``.
Configure the Route
-------------------
-By default, the symfony routing components requires that the parameters
+By default, the Symfony routing components requires that the parameters
match the following regex pattern: ``[^/]+``. This means that all characters
are allowed except ``/``.
View
8 cookbook/security/entity_provider.rst
@@ -301,7 +301,7 @@ For this example, the first three methods will return ``true`` whereas the
.. code-block:: php
// src/Acme/UserBundle/Entity/User.php
- namespace Acme\Bundle\UserBundle\Entity;
+ namespace Acme\UserBundle\Entity;
// ...
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
@@ -453,7 +453,7 @@ more users. As a group is also a role, the previous ``getRoles()`` method now
returns the list of related groups::
// src/Acme/UserBundle/Entity/User.php
- namespace Acme\Bundle\UserBundle\Entity;
+ namespace Acme\UserBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
// ...
@@ -507,7 +507,7 @@ implements the :class:`Symfony\\Component\\Security\\Core\\Role\\RoleInterface`
that forces it to have a ``getRole()`` method::
// src/Acme/Bundle/UserBundle/Entity/Group.php
- namespace Acme\Bundle\UserBundle\Entity;
+ namespace Acme\UserBundle\Entity;
use Symfony\Component\Security\Core\Role\RoleInterface;
use Doctrine\Common\Collections\ArrayCollection;
@@ -563,7 +563,7 @@ relationship in the ``UserRepository::loadUserByUsername()`` method. This will
fetch the user and his associated roles / groups with a single query::
// src/Acme/UserBundle/Entity/UserRepository.php
- namespace Acme\Bundle\UserBundle\Entity;
+ namespace Acme\UserBundle\Entity;
// ...
View
2 cookbook/service_container/event_listener.rst
@@ -11,7 +11,7 @@ component and can be viewed in the :class:`Symfony\\Component\\HttpKernel\\Kerne
To hook into an event and add your own custom logic, you have to create
a service that will act as an event listener on that event. In this entry,
you will create a service that will act as an Exception Listener, allowing
-us to modify how exceptions are shown by our application. The ``KernelEvents::EXCEPTION``
+you to modify how exceptions are shown by our application. The ``KernelEvents::EXCEPTION``
event is just one of the core kernel events::
// src/Acme/DemoBundle/Listener/AcmeExceptionListener.php
View
2 cookbook/service_container/scopes.rst
@@ -35,7 +35,7 @@ when compiling the container. Read the sidebar below for more details.
Imagine you've configured a `my_mailer` service. You haven't configured
the scope of the service, so it defaults to `container`. In other words,
- everytime you ask the container for the `my_mailer` service, you get
+ every time you ask the container for the `my_mailer` service, you get
the same object back. This is usually how you want your services to work.
Imagine, however, that you need the `request` service in your `my_mailer`
View
14 cookbook/testing/doctrine.rst
@@ -32,11 +32,14 @@ which makes all of this quite easy::
*/
private $em;
+ /**
+ * {@inheritDoc}
+ */
public function setUp()
{
static::$kernel = static::createKernel();
static::$kernel->boot();
- $this->em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
+ $this->em = static::$kernel->getContainer()->get('doctrine')->getManager();
}
public function testSearchByCategoryName()
@@ -48,4 +51,13 @@ which makes all of this quite easy::
$this->assertCount(1, $products);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function tearDown()
+ {
+ parent::tearDown();
+ $this->em->close();
+ }
}
View
2 cookbook/workflow/new_project_svn.rst
@@ -84,7 +84,7 @@ To get started, you'll need to download Symfony2 and get the basic Subversion se
$ svn propset svn:ignore "bundles" web
- $ svn ci -m "commit basic symfony ignore list (vendor, app/bootstrap*, app/config/parameters.yml, app/cache/*, app/logs/*, web/bundles)"
+ $ svn ci -m "commit basic Symfony ignore list (vendor, app/bootstrap*, app/config/parameters.yml, app/cache/*, app/logs/*, web/bundles)"
6. The rest of the files can now be added and committed to the project:
View
8 quick_tour/the_architecture.rst
@@ -118,7 +118,7 @@ a single ``Bundle`` class that describes it::
return $bundles;
}
-In addition to the ``AcmeDemoBundle`` that we have already talked about, notice
+In addition to the ``AcmeDemoBundle`` that was already talked about, notice
that the kernel also enables other bundles such as the ``FrameworkBundle``,
``DoctrineBundle``, ``SwiftmailerBundle``, and ``AsseticBundle`` bundle.
They are all part of the core framework.
@@ -272,8 +272,8 @@ If you follow these conventions, then you can use :doc:`bundle inheritance</cook
to "override" files, controllers or templates. For example, you can create
a bundle - ``AcmeNewBundle`` - and specify that it overrides ``AcmeDemoBundle``.
When Symfony loads the ``AcmeDemoBundle:Welcome:index`` controller, it will
-first look for the ``WelcomeController`` class in ``AcmeNewBundle`` and, if
-it doesn't exist, then look inside ``AcmeDemoBundle``. This means that one bundle
+first look for the ``WelcomeController`` class in ``AcmeNewBundle`` and, if
+it doesn't exist, then look inside ``AcmeDemoBundle``. This means that one bundle
can override almost any part of another bundle!
Do you understand now why Symfony2 is so flexible? Share your bundles between
@@ -340,4 +340,4 @@ any topic you want.
.. _standards: http://symfony.com/PSR0
.. _convention: http://pear.php.net/
.. _Composer: http://getcomposer.org
-.. _`Composer-Autoloader`: http://getcomposer.org/doc/01-basic-usage.md#autoloading
+.. _`Composer-Autoloader`: http://getcomposer.org/doc/01-basic-usage.md#autoloading
View
27 quick_tour/the_big_picture.rst
@@ -17,8 +17,25 @@ Downloading Symfony2
--------------------
First, check that you have installed and configured a Web server (such as
-Apache) with the most recent PHP version possible (PHP 5.3.8 or newer is
-recommended).
+Apache) with PHP 5.3.3 or higher.
+
+.. tip::
+
+ If you have PHP 5.4, you could use the built-in web server. The built-in
+ server should be used only for development purpose, but it can help you
+ to start your project quickly and easily.
+
+ Just use this command to launch the server:
+
+ .. code-block:: bash
+
+ $ php -S localhost:80 -t /path/to/www
+
+ where "/path/to/www" is the path to some directory on your machine that
+ you'll extract Symfony into so that the eventual URL to your application
+ is "http://localhost/Symfony/app_dev.php". You can also extract Symfony
+ first and then start the web server in the Symfony "web" directory. If
+ you do this, the URL to your application will be "http://localhost/app_dev.php".
Ready? Start by downloading the "`Symfony2 Standard Edition`_", a Symfony
:term:`distribution` that is preconfigured for the most common use cases and
@@ -240,7 +257,7 @@ the ``Acme\DemoBundle\Controller\WelcomeController`` class::
.. tip::
- You could have used the full class and method name -
+ You could have used the full class and method name -
``Acme\DemoBundle\Controller\WelcomeController::indexAction`` - for the
``_controller`` value. But if you follow some simple conventions, the
logical name is shorter and allows for more flexibility.
@@ -364,12 +381,12 @@ templates work in Symfony2.
Bundles
~~~~~~~
-You might have wondered why the :term:`bundle` word is used in many names we
+You might have wondered why the :term:`bundle` word is used in many names you
have seen so far. All the code you write for your application is organized in
bundles. In Symfony2 speak, a bundle is a structured set of files (PHP files,
stylesheets, JavaScripts, images, ...) that implements a single feature (a
blog, a forum, ...) and which can be easily shared with other developers. As
-of now, we have manipulated one bundle, ``AcmeDemoBundle``. You will learn
+of now, you have manipulated one bundle, ``AcmeDemoBundle``. You will learn
more about bundles in the last chapter of this tutorial.
.. _quick-tour-big-picture-environments:
View
16 quick_tour/the_controller.rst
@@ -1,8 +1,8 @@
The Controller
==============
-Still with us after the first two parts? You are already becoming a Symfony2
-addict! Without further ado, let's discover what controllers can do for you.
+Still here after the first two parts? You are already becoming a Symfony2
+addict! Without further ado, discover what controllers can do for you.
Using Formats
-------------
@@ -74,7 +74,7 @@ method::
return $this->redirect($this->generateUrl('_demo_hello', array('name' => 'Lucas')));
-The ``generateUrl()`` is the same method as the ``path()`` function we used in
+The ``generateUrl()`` is the same method as the ``path()`` function used in the
templates. It takes the route name and an array of parameters as arguments and
returns the associated friendly URL.
@@ -263,8 +263,8 @@ In this example, the resource will be cached for a day. But you can also use
validation instead of expiration or a combination of both if that fits your
needs better.
-Resource caching is managed by the Symfony2 built-in reverse proxy. But because
-caching is managed using regular HTTP cache headers, you can replace the
+Resource caching is managed by the Symfony2 built-in reverse proxy. But because
+caching is managed using regular HTTP cache headers, you can replace the
built-in reverse proxy with Varnish or Squid and easily scale your application.
.. note::
@@ -276,8 +276,8 @@ built-in reverse proxy with Varnish or Squid and easily scale your application.
Final Thoughts
--------------
-That's all there is to it, and I'm not even sure we have spent the full
-10 minutes. We briefly introduced bundles in the first part, and all the
-features we've learned about so far are part of the core framework bundle.
+That's all there is to it, and I'm not even sure you'll have spent the full
+10 minutes. You were briefly introduced to bundles in the first part, and all the
+features you've learned about so far are part of the core framework bundle.
But thanks to bundles, everything in Symfony2 can be extended or replaced.
That's the topic of the :doc:`next part of this tutorial<the_architecture>`.
View
4 quick_tour/the_view.rst
@@ -17,7 +17,7 @@ Getting familiar with Twig
.. tip::
- If you want to learn Twig, we highly recommend you to read its official
+ If you want to learn Twig, it's highly recommended you read its official
`documentation`_. This section is just a quick overview of the main
concepts.
@@ -98,7 +98,7 @@ Decorating Templates
--------------------
More often than not, templates in a project share common elements, like the
-well-known header and footer. In Symfony2, we like to think about this problem
+well-known header and footer. In Symfony2, you think about this problem
differently: a template can be decorated by another one. This works exactly
the same as PHP classes: template inheritance allows you to build a base
"layout" template that contains all the common elements of your site and
View
4 reference/configuration/doctrine.rst
@@ -40,7 +40,7 @@ Configuration Reference
# True to use as persistent connection for the ibm_db2 driver
persistent: ~
- # The protocol to use for the ibm_db2 driver (default to TCPIP if ommited)
+ # The protocol to use for the ibm_db2 driver (default to TCPIP if omitted)
protocol: ~
# True to use dbname as service name instead of SID for Oracle
@@ -85,7 +85,7 @@ Configuration Reference
# True to use as persistent connection for the ibm_db2 driver
persistent: ~
- # The protocol to use for the ibm_db2 driver (default to TCPIP if ommited)
+ # The protocol to use for the ibm_db2 driver (default to TCPIP if omitted)
protocol: ~
# True to use dbname as service name instead of SID for Oracle
View
4 reference/configuration/framework.rst
@@ -226,8 +226,8 @@ would be ``/images/logo.png?version=5``.
is not limited to producing versioned query strings.
The pattern receives the asset's original path and version as its first and
- second parameters, respectively. Since the asset's path is one parameter, we
- cannot modify it in-place (e.g. ``/images/logo-v5.png``); however, we can
+ second parameters, respectively. Since the asset's path is one parameter, you
+ cannot modify it in-place (e.g. ``/images/logo-v5.png``); however, you can
prefix the asset's path using a pattern of ``version-%%2$s/%%1$s``, which
would result in the path ``version-5/images/logo.png``.
View
20 reference/constraints/Valid.rst
@@ -16,7 +16,7 @@ object and all sub-objects associated with it.
Basic Usage
-----------
-In the following example, we create two classes ``Author`` and ``Address``
+In the following example, create two classes ``Author`` and ``Address``
that both have constraints on their properties. Furthermore, ``Author`` stores
an ``Address`` instance in the ``$address`` property.
@@ -121,7 +121,7 @@ an ``Address`` instance in the ``$address`` property.
* @Assert\NotBlank
*/
protected $lastName;
-
+
protected $address;
}
@@ -131,13 +131,13 @@ an ``Address`` instance in the ``$address`` property.
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Length;
-
+
class Address
{
protected $street;
protected $zipCode;
-
+
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('street', new NotBlank());
@@ -152,15 +152,15 @@ an ``Address`` instance in the ``$address`` property.
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Length;
-
+
class Author
{
protected $firstName;
protected $lastName;
-
+
protected $address;
-
+
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('firstName', new NotBlank());
@@ -200,7 +200,7 @@ property.
class Author
{
/* ... */
-
+
/**
* @Assert\Valid
*/
@@ -212,11 +212,11 @@ property.
// src/Acme/HelloBundle/Author.php
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints\Valid;
-
+
class Author
{
protected $address;
-
+
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('address', new Valid());
View
20 reference/forms/types/collection.rst
@@ -52,19 +52,19 @@ The simplest way to render this is all at once:
.. configuration-block::
.. code-block:: jinja
-
+
{{ form_row(form.emails) }}
.. code-block:: php
-
+
<?php echo $view['form']->row($form['emails']) ?>
A much more flexible method would look like this:
.. configuration-block::
.. code-block:: html+jinja
-
+
{{ form_label(form.emails) }}
{{ form_errors(form.emails) }}
@@ -81,7 +81,7 @@ A much more flexible method would look like this:
<?php echo $view['form']->label($form['emails']) ?>
<?php echo $view['form']->errors($form['emails']) ?>
-
+
<ul>
<?php foreach ($form['emails'] as $emailField): ?>
<li>
@@ -142,7 +142,7 @@ you need is the JavaScript:
.. configuration-block::
.. code-block:: html+jinja
-
+
<form action="..." method="POST" {{ form_enctype(form) }}>
{# ... #}
@@ -155,9 +155,9 @@ you need is the JavaScript:
</li>
{% endfor %}
</ul>
-
+
<a href="#" id="add-another-email">Add another email</a>
-
+
{# ... #}
</form>
@@ -192,7 +192,7 @@ you need is the JavaScript:
is automatically available on the ``data-prototype`` attribute of the
element (e.g. ``div`` or ``table``) that surrounds your collection. The
only difference is that the entire "form row" is rendered for you, meaning
- you wouldn't have to wrap it in any container element like we've done
+ you wouldn't have to wrap it in any container element as was done
above.
Field Options
@@ -295,11 +295,11 @@ collection field:
.. configuration-block::
.. code-block:: jinja
-
+
{{ form_row(form.emails.vars.prototype) }}
.. code-block:: php
-
+
<?php echo $view['form']->row($form['emails']->getVar('prototype')) ?>
Note that all you really need is the "widget", but depending on how you're
View
6 reference/forms/types/options/by_reference.rst.inc
@@ -8,7 +8,7 @@ to be called on the underlying object. In some cases, however, ``setName``
may *not* be called. Setting ``by_reference`` ensures that the setter is
called in all cases.
-To understand this further, let's look at a simple example::
+To explain this further, here's a simple example::
$builder = $this->createFormBuilder($article);
$builder
@@ -28,7 +28,7 @@ when you call ``bind`` on the form::
Notice that ``setAuthor`` is not called. The author is modified by reference.
-If we set ``by_reference`` to false, binding looks like this::
+If you set ``by_reference`` to false, binding looks like this::
$article->setTitle('...');
$author = $article->getAuthor();
@@ -42,4 +42,4 @@ call the setter on the parent object.
Similarly, if you're using the :doc:`collection</reference/forms/types/collection>`
form type where your underlying collection data is an object (like with Doctrine's
``ArrayCollection``), then ``by_reference`` must be set to ``false`` if you
-need the setter (e.g. ``setAuthors``) to be called.
+need the setter (e.g. ``setAuthors``) to be called.

0 comments on commit d1bcc4e

Please sign in to comment.