Skip to content

Commit 6c5898a

Browse files
committed
Merge branch '2.0'
Conflicts: book/installation.rst
2 parents 7ed12af + 4df5fb8 commit 6c5898a

File tree

4 files changed

+125
-3
lines changed

4 files changed

+125
-3
lines changed

book/installation.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Downloading a Symfony2 Distribution
2222
First, check that you have installed and configured a Web server (such
2323
as Apache) with PHP 5.3.2 or higher. For more information on Symfony2
2424
requirements, see the :doc:`requirements reference</reference/requirements>`.
25+
For information on configuring your specific web server document root, see the
26+
following documentation: `Apache`_ | `Nginx`_ .
2527

2628
Symfony2 packages "distributions", which are fully-functional applications
2729
that include the Symfony2 core libraries, a selection of useful bundles, a
@@ -233,4 +235,7 @@ download all the necessary vendor libraries.
233235
.. _`http://symfony.com/download`: http://symfony.com/download
234236
.. _`Git`: http://git-scm.com/
235237
.. _`GitHub Bootcamp`: http://help.github.com/set-up-git-redirect
236-
.. _`Composer`: http://getcomposer.org/
238+
.. _`Composer`: http://getcomposer.org/
239+
.. _`Apache`: http://httpd.apache.org/docs/current/mod/core.html#documentroot
240+
.. _`Nginx`: http://wiki.nginx.org/HttpCoreModule#root
241+

book/page_creation.rst

+7-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ greeted. To create the page, follow the simple two-step process.
4646
The tutorial assumes that you've already downloaded Symfony2 and configured
4747
your webserver. The above URL assumes that ``localhost`` points to the
4848
``web`` directory of your new Symfony2 project. For detailed information
49-
on this process, see the :doc:`Installing Symfony2</book/installation>`.
49+
on this process, see the documentation on the web server you are using.
50+
Here's the relevant documentation page for some web server you might be using:
51+
52+
* For Apache HTTP Server, refer to `Apache's DirectoryIndex documentation`_.
53+
* For Nginx, refer to `Nginx HttpCoreModule location documentation`_.
5054

5155
Before you begin: Create the Bundle
5256
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -989,3 +993,5 @@ to rapidly develop applications.
989993
.. _`Twig`: http://twig.sensiolabs.org
990994
.. _`third-party bundles`: http://symfony2bundles.org/
991995
.. _`Symfony Standard Edition`: http://symfony.com/download
996+
.. _`Apache's DirectoryIndex documentation`: http://httpd.apache.org/docs/2.0/mod/mod_dir.html
997+
.. _`Nginx HttpCoreModule location documentation`: http://wiki.nginx.org/HttpCoreModule#location

book/translation.rst

+111
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,117 @@ The translation of database content should be handled by Doctrine through
855855
the `Translatable Extension`_. For more information, see the documentation
856856
for that library.
857857

858+
Translating Constraint Messages
859+
-------------------------------
860+
861+
The best way to understand constraint translation is to see it in action. To start,
862+
suppose you've created a plain-old-PHP object that you need to use somewhere in
863+
your application:
864+
865+
.. code-block:: php
866+
867+
// src/Acme/BlogBundle/Entity/Author.php
868+
namespace Acme\BlogBundle\Entity;
869+
870+
class Author
871+
{
872+
public $name;
873+
}
874+
875+
Add constraints though any of the supported methods. Set the message option to the
876+
translation source text. For example, to guarantee that the $name property is not
877+
empty, add the following:
878+
879+
.. configuration-block::
880+
881+
.. code-block:: yaml
882+
883+
# src/Acme/BlogBundle/Resources/config/validation.yml
884+
Acme\BlogBundle\Entity\Author:
885+
properties:
886+
name:
887+
- NotBlank: { message: "author.name.not_blank" }
888+
889+
.. code-block:: php-annotations
890+
891+
// src/Acme/BlogBundle/Entity/Author.php
892+
use Symfony\Component\Validator\Constraints as Assert;
893+
894+
class Author
895+
{
896+
/**
897+
* @Assert\NotBlank(message = "author.name.not_blank")
898+
*/
899+
public $name;
900+
}
901+
902+
.. code-block:: xml
903+
904+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
905+
<?xml version="1.0" encoding="UTF-8" ?>
906+
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
907+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
908+
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
909+
910+
<class name="Acme\BlogBundle\Entity\Author">
911+
<property name="name">
912+
<constraint name="NotBlank">
913+
<option name="message">author.name.not_blank</option>
914+
</constraint>
915+
</property>
916+
</class>
917+
</constraint-mapping>
918+
919+
.. code-block:: php
920+
921+
// src/Acme/BlogBundle/Entity/Author.php
922+
923+
use Symfony\Component\Validator\Mapping\ClassMetadata;
924+
use Symfony\Component\Validator\Constraints\NotBlank;
925+
926+
class Author
927+
{
928+
public $name;
929+
930+
public static function loadValidatorMetadata(ClassMetadata $metadata)
931+
{
932+
$metadata->addPropertyConstraint('name', new NotBlank(array(
933+
'message' => 'author.name.not_blank'
934+
)));
935+
}
936+
}
937+
938+
Create a translation file under the ``validators`` catalog for the constraint messages, typically in the ``Resources/translations/`` directory of the bundle. See `Message Catalogues`_ for more details.
939+
940+
.. configuration-block::
941+
942+
.. code-block:: xml
943+
944+
<!-- validators.fr.xliff -->
945+
<?xml version="1.0"?>
946+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
947+
<file source-language="en" datatype="plaintext" original="file.ext">
948+
<body>
949+
<trans-unit id="1">
950+
<source>author.name.not_blank</source>
951+
<target>Please enter an author name.</target>
952+
</trans-unit>
953+
</body>
954+
</file>
955+
</xliff>
956+
957+
.. code-block:: php
958+
959+
// validators.fr.php
960+
return array(
961+
'author.name.not_blank' => 'Please enter an author name.',
962+
);
963+
964+
.. code-block:: yaml
965+
966+
# validators.fr.yml
967+
author.name.not_blank: Please enter an author name.
968+
858969
Summary
859970
-------
860971

components/dependency_injection.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ Loading a yaml config file:
227227
$loader = new YamlFileLoader($container, new FileLocator(__DIR__));
228228
$loader->load('services.yml');
229229
230-
The ``newsletter_manager`` and `` mailer`` services can be set up using config files:
230+
The ``newsletter_manager`` and ``mailer`` services can be set up using config files:
231231

232232
.. configuration-block::
233233

0 commit comments

Comments
 (0)