From 96fb64f66203af568eeb36aed9683da30bd376e5 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 10 Aug 2014 13:40:34 +0200 Subject: [PATCH] [Book] consistent and complete config examples Make configuration examples in the book consistent throughout the different configuration formats. Also fixing several syntax issues. --- book/controller.rst | 12 ++ book/doctrine.rst | 91 +++++----- book/forms.rst | 29 ++-- book/http_cache.rst | 8 +- book/http_fundamentals.rst | 3 +- book/internals.rst | 23 ++- book/page_creation.rst | 40 +++-- book/propel.rst | 58 ++++--- book/routing.rst | 48 ++++-- book/security.rst | 330 +++++++++++++++++++++++++++---------- book/service_container.rst | 18 +- book/templating.rst | 28 +++- book/testing.rst | 6 +- book/translation.rst | 17 +- book/validation.rst | 6 +- 15 files changed, 478 insertions(+), 239 deletions(-) diff --git a/book/controller.rst b/book/controller.rst index a351e3947d8..da861c49808 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -170,10 +170,16 @@ to the controller: .. code-block:: php // app/config/routing.php + use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; + + $collection = new RouteCollection(); $collection->add('hello', new Route('/hello/{name}', array( '_controller' => 'AcmeHelloBundle:Hello:index', ))); + return $collection; + Going to ``/hello/ryan`` now executes the ``HelloController::indexAction()`` controller and passes in ``ryan`` for the ``$name`` variable. Creating a "page" means simply creating a controller method and associated route. @@ -257,11 +263,17 @@ example: .. code-block:: php // app/config/routing.php + use Symfony\Component\Routing\Route; + use Symfony\Component\Routing\RouteCollection; + + $collection = new RouteCollection(); $collection->add('hello', new Route('/hello/{firstName}/{lastName}', array( '_controller' => 'AcmeHelloBundle:Hello:index', 'color' => 'green', ))); + return $collection; + The controller for this can take several arguments:: public function indexAction($firstName, $lastName, $color) diff --git a/book/doctrine.rst b/book/doctrine.rst index 84a54b49017..996dcdbee9f 100644 --- a/book/doctrine.rst +++ b/book/doctrine.rst @@ -85,7 +85,7 @@ information. By convention, this information is usually configured in an xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:doctrine="http://symfony.com/schema/dic/doctrine" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> + http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> + password="%database_password%" /> - .. code-block:: php @@ -175,16 +173,14 @@ for you: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:doctrine="http://symfony.com/schema/dic/doctrine" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> - - - - + http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> + + + .. code-block:: php @@ -319,17 +315,17 @@ in a number of different formats including YAML, XML or directly inside the + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping + http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + - - - + + + @@ -826,13 +822,15 @@ To do this, add the name of the repository class to your mapping definition: + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping + http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> + + - - + @@ -945,17 +943,18 @@ To relate the ``Category`` and ``Product`` entities, start by creating a .. code-block:: xml + + http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - + mapped-by="category" /> + + http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - - + join-column="category"> + + @@ -1306,6 +1304,8 @@ the current date, only when the entity is first persisted (i.e. inserted): .. code-block:: php-annotations + // src/Acme/StoreBundle/Entity/Product.php + /** * @ORM\PrePersist */ @@ -1328,16 +1328,15 @@ the current date, only when the entity is first persisted (i.e. inserted): + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping + http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - - - - + + + + diff --git a/book/forms.rst b/book/forms.rst index b3e3c16c1ed..34de2a148df 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -129,7 +129,7 @@ corresponding to the ``task`` and ``dueDate`` properties of the ``Task`` class. You've also assigned each a "type" (e.g. ``text``, ``date``), which, among other things, determines which HTML form tag(s) is rendered for that field. -Finally, you added a submit button with a custom label for submitting the form to +Finally, you added a submit button with a custom label for submitting the form to the server. .. versionadded:: 2.3 @@ -1126,20 +1126,21 @@ easy to use in your application. + - - - + + + + .. code-block:: php // src/Acme/TaskBundle/Resources/config/services.php - use Symfony\Component\DependencyInjection\Definition; - $container ->register( 'acme_demo.form.type.task', @@ -1590,13 +1591,13 @@ file: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:twig="http://symfony.com/schema/dic/twig" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd"> + http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd"> - - AcmeTaskBundle:Form:fields.html.twig - - + + AcmeTaskBundle:Form:fields.html.twig + + @@ -1676,7 +1677,7 @@ file: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> diff --git a/book/http_cache.rst b/book/http_cache.rst index 4b25eda1ebd..0cebde1933b 100644 --- a/book/http_cache.rst +++ b/book/http_cache.rst @@ -866,8 +866,7 @@ First, to use ESI, be sure to enable it in your application configuration: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/symfony - http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> @@ -880,7 +879,7 @@ First, to use ESI, be sure to enable it in your application configuration: // app/config/config.php $container->loadFromExtension('framework', array( // ... - 'esi' => array('enabled' => true), + 'esi' => array('enabled' => true), )); Now, suppose you have a page that is relatively static, except for a news @@ -988,8 +987,9 @@ that must be enabled in your configuration: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:doctrine="http://symfony.com/schema/dic/framework" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + diff --git a/book/http_fundamentals.rst b/book/http_fundamentals.rst index fa0d80e57fb..b42e56d94ba 100644 --- a/book/http_fundamentals.rst +++ b/book/http_fundamentals.rst @@ -429,6 +429,7 @@ by adding an entry for ``/contact`` to your routing configuration file: .. code-block:: xml + add('contact', new Route('/contact', array( diff --git a/book/internals.rst b/book/internals.rst index ee8bcca6afd..1c3356aeaf1 100644 --- a/book/internals.rst +++ b/book/internals.rst @@ -578,7 +578,7 @@ the configuration for the development environment: xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/webprofiler http://symfony.com/schema/dic/webprofiler/webprofiler-1.0.xsd - http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> @@ -588,9 +588,7 @@ the configuration for the development environment: + intercept-redirects="true" /> .. code-block:: php @@ -604,7 +602,6 @@ the configuration for the development environment: $container->loadFromExtension('web_profiler', array( 'toolbar' => true, 'intercept_redirects' => true, - 'verbose' => true, )); When ``only_exceptions`` is set to ``true``, the profiler only collects data @@ -634,18 +631,18 @@ If you enable the web profiler, you also need to mount the profiler routes: + prefix="/_profiler" /> .. code-block:: php - $collection->addCollection( - $loader->import( - "@WebProfilerBundle/Resources/config/routing/profiler.xml" - ), - '/_profiler' - ); + use Symfony\Component\Routing\RouteCollection; + + $profiler = $loader->import('@WebProfilerBundle/Resources/config/routing/profiler.xml'); + $profiler->addPrefix('/_profiler'); + + $collection = new RouteCollection(); + $collection->addCollection($profiler); As the profiler adds some overhead, you might want to enable it only under certain circumstances in the production environment. The ``only_exceptions`` diff --git a/book/page_creation.rst b/book/page_creation.rst index 3d251aacc99..c689602a3f5 100644 --- a/book/page_creation.rst +++ b/book/page_creation.rst @@ -152,7 +152,8 @@ an entry when you generated the ``AcmeHelloBundle``: xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - @@ -160,21 +161,27 @@ an entry when you generated the ``AcmeHelloBundle``: // app/config/routing.php use Symfony\Component\Routing\RouteCollection; - use Symfony\Component\Routing\Route; + + $acmeHello = $loader->import('@AcmeHelloBundle/Resources/config/routing.php'); + $acmeHello->addPrefix('/'); $collection = new RouteCollection(); - $collection->addCollection( - $loader->import('@AcmeHelloBundle/Resources/config/routing.php'), - '/' - ); + $collection->addCollection($acmeHello); return $collection; This entry is pretty basic: it tells Symfony to load routing configuration -from the ``Resources/config/routing.yml`` file that lives inside the ``AcmeHelloBundle``. +from the ``Resources/config/routing.yml`` (``routing.xml`` or ``routing.php`` +in the XML and PHP code example respectively) file that lives inside the ``AcmeHelloBundle``. This means that you place routing configuration directly in ``app/config/routing.yml`` or organize your routes throughout your application, and import them from here. +.. note:: + + You are not limited to load routing configurations that are of the same + format. For example, you could also load a YAML file in an XML configuration + and vice versa. + Now that the ``routing.yml`` file from the bundle is being imported, add the new route that defines the URL of the page that you're about to create: @@ -791,9 +798,9 @@ format you prefer: xmlns:framework="http://symfony.com/schema/dic/symfony" xmlns:twig="http://symfony.com/schema/dic/twig" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd - http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd + http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd"> + @@ -812,16 +819,16 @@ format you prefer: .. code-block:: php + // app/config/config.php $this->import('parameters.yml'); $this->import('security.yml'); $container->loadFromExtension('framework', array( - 'secret' => '%secret%', - 'router' => array( + 'secret' => '%secret%', + 'router' => array( 'resource' => '%kernel.root_dir%/config/routing.php', ), // ... - ), )); // Twig Configuration @@ -985,20 +992,19 @@ the configuration file for the ``dev`` environment. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + + .. code-block:: php diff --git a/book/propel.rst b/book/propel.rst index 6b239374e64..b48b5f3a5a1 100644 --- a/book/propel.rst +++ b/book/propel.rst @@ -91,28 +91,31 @@ of your ``AcmeStoreBundle``: .. code-block:: xml - + defaultIdMethod="native"> + - - + + - - + size="100" /> + + +
@@ -305,28 +308,35 @@ Start by adding the ``category`` definition in your ``schema.xml``: .. code-block:: xml - + - - - - - @@ -335,13 +345,15 @@ Start by adding the ``category`` definition in your ``schema.xml``:
- - diff --git a/book/routing.rst b/book/routing.rst index 3d05d462d6a..4b9898f83a5 100644 --- a/book/routing.rst +++ b/book/routing.rst @@ -173,7 +173,7 @@ file: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> @@ -210,12 +210,14 @@ A basic route consists of just two parts: the ``path`` to match and a .. code-block:: yaml + # app/config/routing.yml _welcome: path: / defaults: { _controller: AcmeDemoBundle:Main:homepage } .. code-block:: xml + `); -* ``_locale``: Used to set the locale on the request (:ref:`read more `); +* ``_locale``: Used to set the locale on the request (:ref:`read more `). .. index:: single: Routing; Controllers @@ -1044,7 +1074,8 @@ instead of simply ``/hello/{name}``: xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - @@ -1053,13 +1084,10 @@ instead of simply ``/hello/{name}``: // app/config/routing.php use Symfony\Component\Routing\RouteCollection; - $collection = new RouteCollection(); - - $acmeHello = $loader->import( - "@AcmeHelloBundle/Resources/config/routing.php" - ); + $acmeHello = $loader->import('@AcmeHelloBundle/Resources/config/routing.php'); $acmeHello->addPrefix('/admin'); + $collection = new RouteCollection(); $collection->addCollection($acmeHello); return $collection; diff --git a/book/security.rst b/book/security.rst index 03344bcb655..c4f259c874f 100644 --- a/book/security.rst +++ b/book/security.rst @@ -123,7 +123,7 @@ authentication (i.e. the old-school username/password box): 'ryan' => array( 'password' => 'ryanpass', 'roles' => 'ROLE_USER', - ), + ), 'admin' => array( 'password' => 'kitten', 'roles' => 'ROLE_ADMIN', @@ -455,7 +455,7 @@ Next, create the controller that will display the login form:: } else { $error = ''; } - + // last username entered by the user $lastUsername = (null === $session) ? '' : $session->get(SecurityContextInterface::LAST_USERNAME); @@ -599,17 +599,26 @@ see :doc:`/cookbook/security/form_login`. .. code-block:: yaml + # app/config/security.yml + + # ... access_control: - { path: ^/, roles: ROLE_ADMIN } .. code-block:: xml + + + .. code-block:: php + // app/config/security.php + + // ... 'access_control' => array( array('path' => '^/', 'role' => 'ROLE_ADMIN'), ), @@ -620,12 +629,18 @@ see :doc:`/cookbook/security/form_login`. .. code-block:: yaml + # app/config/security.yml + + # ... access_control: - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/, roles: ROLE_ADMIN } .. code-block:: xml + + + @@ -633,6 +648,9 @@ see :doc:`/cookbook/security/form_login`. .. code-block:: php + // app/config/security.php + + // ... 'access_control' => array( array('path' => '^/login', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'), array('path' => '^/', 'role' => 'ROLE_ADMIN'), @@ -646,6 +664,9 @@ see :doc:`/cookbook/security/form_login`. .. code-block:: yaml + # app/config/security.yml + + # ... firewalls: login_firewall: pattern: ^/login$ @@ -656,6 +677,9 @@ see :doc:`/cookbook/security/form_login`. .. code-block:: xml + + + @@ -665,6 +689,9 @@ see :doc:`/cookbook/security/form_login`. .. code-block:: php + // app/config/security.php + + // ... 'firewalls' => array( 'login_firewall' => array( 'pattern' => '^/login$', @@ -742,11 +769,21 @@ You can define as many URL patterns as you need - each is a regular expression. .. code-block:: xml - - - - - + + + + + + + + + + + .. code-block:: php @@ -814,15 +851,30 @@ Take the following ``access_control`` entries as an example: .. code-block:: xml - - - - - - + + + + + + + + + + + + + + .. code-block:: php + // app/config/security.php + $container->loadFromExtension('security', array( + // ... 'access_control' => array( array( 'path' => '^/admin', @@ -844,6 +896,7 @@ Take the following ``access_control`` entries as an example: 'role' => 'ROLE_USER', ), ), + )); For each incoming request, Symfony will decide which ``access_control`` to use based on the URI, the client's IP address, the incoming host name, @@ -945,14 +998,29 @@ given prefix, ``/esi``, from outside access: .. code-block:: xml - - - - + + + + + + + + + + + + .. code-block:: php + // app/config/security.php + $container->loadFromExtension('security', array( + // ... 'access_control' => array( array( 'path' => '^/esi', @@ -964,6 +1032,7 @@ given prefix, ``/esi``, from outside access: 'role' => 'ROLE_NO_ACCESS' ), ), + )); Here is how it works when the path is ``/esi/something`` coming from the ``10.0.0.1`` IP: @@ -1008,13 +1077,25 @@ the user will be redirected to ``https``: .. code-block:: xml + + + + - + + .. code-block:: php + // app/config/security.php + $container->loadFromExtension('security', array( 'access_control' => array( array( 'path' => '^/cart/checkout', @@ -1022,6 +1103,7 @@ the user will be redirected to ``https``: 'requires_channel' => 'https', ), ), + )); Users ----- @@ -1067,15 +1149,23 @@ In fact, you've seen this already in the example in this chapter. .. code-block:: xml - - - - - - - - - + + + + + + + + + + + + + .. code-block:: php @@ -1192,11 +1282,19 @@ class: .. code-block:: xml - - - - - + + + + + + + + + .. code-block:: php @@ -1262,24 +1360,34 @@ do the following: .. code-block:: xml - - - - - - - - - - - + + + + + + + + + + + + + + + .. code-block:: php @@ -1424,22 +1532,30 @@ a new provider that chains the two together: .. code-block:: xml - - - - in_memory - user_db - - - - - - - - - - - + + + + + + + in_memory + user_db + + + + + + + + + + + + .. code-block:: php @@ -1484,6 +1600,7 @@ the first provider is always used: firewalls: secured_area: # ... + pattern: ^/ provider: user_db http_basic: realm: "Secured Demo Area" @@ -1493,13 +1610,21 @@ the first provider is always used: .. code-block:: xml - - - - - - - + + + + + + + + + + + .. code-block:: php @@ -1508,6 +1633,7 @@ the first provider is always used: 'firewalls' => array( 'secured_area' => array( // ... + 'pattern' => '^/', 'provider' => 'user_db', 'http_basic' => array( // ... @@ -1564,10 +1690,18 @@ rules by creating a role hierarchy: .. code-block:: xml - - ROLE_USER - ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH - + + + + + ROLE_USER + ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH + + .. code-block:: php @@ -1716,13 +1850,21 @@ the firewall can handle this automatically for you when you activate the .. code-block:: xml - - + + + + + + + + - - - - + + .. code-block:: php @@ -1827,11 +1969,19 @@ cookie will be ever created by Symfony2): .. code-block:: xml - - - - - + + + + + + + + + .. code-block:: php diff --git a/book/service_container.rst b/book/service_container.rst index b147b233b14..a0150c6b6d1 100644 --- a/book/service_container.rst +++ b/book/service_container.rst @@ -416,7 +416,7 @@ configuration. .. code-block:: php // app/config/config.php - $this->import('@AcmeHelloBundle/Resources/config/services.php'); + $loader->import('@AcmeHelloBundle/Resources/config/services.php'); The ``imports`` directive allows your application to include service container configuration resources from any other location (most commonly from bundles). @@ -484,7 +484,7 @@ invokes the service container extension inside the FrameworkBundle: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> @@ -828,7 +828,7 @@ it exists and do nothing if it doesn't: )); In YAML, the special ``@?`` syntax tells the service container that the dependency -is optional. Of course, the ``NewsletterManager`` must also be written to +is optional. Of course, the ``NewsletterManager`` must also be rewritten to allow for an optional dependency:: public function __construct(Mailer $mailer = null) @@ -892,6 +892,7 @@ Configuring the service container is easy: .. code-block:: yaml + # src/Acme/HelloBundle/Resources/config/services.yml services: newsletter_manager: class: "%newsletter_manager.class%" @@ -899,6 +900,7 @@ Configuring the service container is easy: .. code-block:: xml + setDefinition('newsletter_manager', new Definition( '%newsletter_manager.class%', array( @@ -946,6 +949,7 @@ to be used for a specific purpose. Take the following example: .. code-block:: yaml + # app/config/services.yml services: foo.twig.extension: class: Acme\HelloBundle\Extension\FooExtension @@ -954,19 +958,25 @@ to be used for a specific purpose. Take the following example: .. code-block:: xml + - + .. code-block:: php + // app/config/services.php + use Symfony\Component\DependencyInjection\Definition; + $definition = new Definition('Acme\HelloBundle\Extension\FooExtension'); $definition->addTag('twig.extension'); $container->setDefinition('foo.twig.extension', $definition); diff --git a/book/templating.rst b/book/templating.rst index babfe94881b..f37a4df97f1 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -727,8 +727,9 @@ tags: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + @@ -763,11 +764,11 @@ in your application configuration: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + - + @@ -847,12 +848,14 @@ configuration: .. code-block:: yaml + # app/config/routing.yml _welcome: path: / defaults: { _controller: AcmeDemoBundle:Welcome:index } .. code-block:: xml + add('_welcome', new Route('/', array( '_controller' => 'AcmeDemoBundle:Welcome:index', @@ -885,19 +892,21 @@ To link to the page, just use the ``path`` Twig function and refer to the route: Home -As expected, this will generate the URL ``/``. Now for a more complicated +As expected, this will generate the URL ``/``. Now, for a more complicated route: .. configuration-block:: .. code-block:: yaml + # app/config/routing.yml article_show: path: /article/{slug} defaults: { _controller: AcmeArticleBundle:Article:show } .. code-block:: xml + add('article_show', new Route('/article/{slug}', array( '_controller' => 'AcmeArticleBundle:Article:show', @@ -1169,11 +1182,12 @@ configuration file: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + - + twig diff --git a/book/testing.rst b/book/testing.rst index 7a62022a1f8..bc484bf76dc 100644 --- a/book/testing.rst +++ b/book/testing.rst @@ -494,8 +494,8 @@ force him with the ``followRedirects()`` method:: $client->followRedirects(); -If you pass ``false`` to the ``followRedirects()`` method, the redirects -will no longer be followed:: +If you pass ``false`` to the ``followRedirects()`` method, the redirects +will no longer be followed:: $client->followRedirects(false); @@ -724,7 +724,7 @@ configuration option: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd"> + http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd"> diff --git a/book/translation.rst b/book/translation.rst index ec103e2077a..6b18a4f2718 100644 --- a/book/translation.rst +++ b/book/translation.rst @@ -69,7 +69,7 @@ enable the ``translator`` in your configuration: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> @@ -451,6 +451,7 @@ by the routing system using the special ``_locale`` parameter: .. code-block:: yaml + # app/config/routing.yml contact: path: /{_locale}/contact defaults: { _controller: AcmeDemoBundle:Contact:index } @@ -459,6 +460,7 @@ by the routing system using the special ``_locale`` parameter: .. code-block:: xml + - - en - + + + + + .. code-block:: php diff --git a/book/validation.rst b/book/validation.rst index f0a54ab9b59..7b2cdc5ff82 100644 --- a/book/validation.rst +++ b/book/validation.rst @@ -272,7 +272,7 @@ annotations if you're using the annotation method to specify your constraints: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd - http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> @@ -1139,8 +1139,8 @@ provides a sequence of groups to be validated: + http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> +