diff --git a/book/forms.rst b/book/forms.rst index cc41e14efdd..eac7c02f946 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -48,6 +48,7 @@ going to need to build a form. But before you begin, first focus on the generic { return $this->dueDate; } + public function setDueDate(\DateTime $dueDate = null) { $this->dueDate = $dueDate; diff --git a/book/http_cache.rst b/book/http_cache.rst index eae2857dc9f..c13ba53db0b 100644 --- a/book/http_cache.rst +++ b/book/http_cache.rst @@ -795,13 +795,13 @@ Gateway caches are a great way to make your website perform better. But they have one limitation: they can only cache whole pages. If you can't cache whole pages or if parts of a page has "more" dynamic parts, you are out of luck. Fortunately, Symfony2 provides a solution for these cases, based on a -technology called `ESI`_, or Edge Side Includes. Akamaï wrote this specification +technology called `ESI`_, or Edge Side Includes. Akamai wrote this specification almost 10 years ago, and it allows specific parts of a page to have a different caching strategy than the main page. The ESI specification describes tags you can embed in your pages to communicate with the gateway cache. Only one tag is implemented in Symfony2, ``include``, -as this is the only useful one outside of Akamaï context: +as this is the only useful one outside of Akamai context: .. code-block:: html @@ -936,7 +936,7 @@ used ``render``. .. note:: - Symfony2 detects if a gateway cache supports ESI via another Akamaï + Symfony2 detects if a gateway cache supports ESI via another Akamai specification that is supported out of the box by the Symfony2 reverse proxy. diff --git a/book/includes/_service_container_my_mailer.rst.inc b/book/includes/_service_container_my_mailer.rst.inc index efc2eaeac26..675df06f375 100644 --- a/book/includes/_service_container_my_mailer.rst.inc +++ b/book/includes/_service_container_my_mailer.rst.inc @@ -16,8 +16,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" - > - + > sendmail @@ -33,4 +32,4 @@ $container->setDefinition('my_mailer', new Definition( 'Acme\HelloBundle\Mailer', array('sendmail') - )); \ No newline at end of file + )); diff --git a/book/security.rst b/book/security.rst index 391856bb3ae..12a98e7bd1f 100644 --- a/book/security.rst +++ b/book/security.rst @@ -764,13 +764,13 @@ is used to enforce access. Each ``access_control`` has several options that configure two different things: -* (a) :ref:`should the incoming request match this access control entry ` -* (b) :ref:`once it matches, should some sort of access restriction be enforced `: +#. :ref:`should the incoming request match this access control entry ` +#. :ref:`once it matches, should some sort of access restriction be enforced `: .. _security-book-access-control-matching-options: -(a) Matching Options -.................... +1. Matching Options +................... Symfony2 creates an instance of :class:`Symfony\\Component\\HttpFoundation\\RequestMatcher` for each ``access_control`` entry, which determines whether or not a given @@ -865,8 +865,8 @@ will match any ``ip``, ``host`` or ``method``: .. _security-book-access-control-enforcement-options: -(b) Access Enforcement -...................... +2. Access Enforcement +..................... Once Symfony2 has decided which ``access_control`` entry matches (if any), it then *enforces* access restrictions based on the ``roles`` and ``requires_channel`` diff --git a/book/service_container.rst b/book/service_container.rst index 3dc5698c853..414c819cd8b 100644 --- a/book/service_container.rst +++ b/book/service_container.rst @@ -103,7 +103,7 @@ for you. In order for this to work, you must *teach* the container how to create the ``Mailer`` service. This is done via configuration, which can be specified in YAML, XML or PHP: -.. include includes/_service_container_my_mailer.rst.inc +.. include:: includes/_service_container_my_mailer.rst.inc .. note:: @@ -643,7 +643,7 @@ which has a ``getMailerMethod()`` method on it, which will return a string like ``sendmail`` based on some configuration. Remember that the first argument to the ``my_mailer`` service is the simple string ``sendmail``: -.. include includes/_service_container_my_mailer.rst.inc +.. include:: includes/_service_container_my_mailer.rst.inc But instead of hardcoding this, how could we get this value from the ``getMailerMethod()`` of the new ``mailer_configuration`` service? One way is to use an expression: @@ -874,7 +874,7 @@ Now, just inject the ``request_stack``, which behaves like any normal service: # src/Acme/HelloBundle/Resources/config/services.yml services: newsletter_manager: - class: "Acme\HelloBundle\Newsletter\NewsletterManager" + class: Acme\HelloBundle\Newsletter\NewsletterManager arguments: ["@request_stack"] .. code-block:: xml diff --git a/book/translation.rst b/book/translation.rst index 2c946535284..c27ac70c933 100644 --- a/book/translation.rst +++ b/book/translation.rst @@ -392,7 +392,7 @@ key ``Symfony2 is great``. To find the French translation, Symfony actually checks translation resources for several different locales: 1. First, Symfony looks for the translation in a ``fr_FR`` translation resource - (e.g. ``messages.fr_FR.xfliff``); + (e.g. ``messages.fr_FR.xliff``); 2. If it wasn't found, Symfony looks for the translation in a ``fr`` translation resource (e.g. ``messages.fr.xliff``); diff --git a/components/config/definition.rst b/components/config/definition.rst index a6cdc64d9a3..b635ff2a205 100644 --- a/components/config/definition.rst +++ b/components/config/definition.rst @@ -390,8 +390,8 @@ process is used to remove some of the differences that result from different configuration formats, mainly the differences between YAML and XML. The separator used in keys is typically ``_`` in YAML and ``-`` in XML. For -example, ``auto_connect`` in YAML and ``auto-connect``. The normalization would -make both of these ``auto_connect``. +example, ``auto_connect`` in YAML and ``auto-connect`` in XML. +The normalization would make both of these ``auto_connect``. .. caution:: diff --git a/components/console/helpers/dialoghelper.rst b/components/console/helpers/dialoghelper.rst index 3e46334fab1..e4eec6b3a45 100644 --- a/components/console/helpers/dialoghelper.rst +++ b/components/console/helpers/dialoghelper.rst @@ -12,8 +12,8 @@ helper set, which you can get by calling $dialog = $this->getHelperSet()->get('dialog'); All the methods inside the Dialog Helper have an -:class:`Symfony\\Component\\Console\\Output\\OutputInterface` as first the -argument, the question as the second argument and the default value as last +:class:`Symfony\\Component\\Console\\Output\\OutputInterface` as the first +argument, the question as the second argument and the default value as the last argument. Asking the User for confirmation @@ -52,8 +52,9 @@ if you want to know a bundle name, you can add this to your command:: ); The user will be asked "Please enter the name of the bundle". They can type -some name which will be returned by the ``ask`` method. If they leave it empty, -the default value (``AcmeDemoBundle`` here) is returned. +some name which will be returned by the +:method:`Symfony\\Component\\Console\\Helper\\DialogHelper::ask` method. +If they leave it empty, the default value (``AcmeDemoBundle`` here) is returned. Autocompletion ~~~~~~~~~~~~~~ @@ -222,9 +223,12 @@ this set the seventh argument to ``true``:: return $colors[$c]; }, $selected); - $output->writeln('You have just selected: ' . implode(', ', $selectedColors)); + $output->writeln( + 'You have just selected: ' . implode(', ', $selectedColors) + ); -Now, when the user enters ``1,2``, the result will be: ``You have just selected: blue, yellow``. +Now, when the user enters ``1,2``, the result will be: +``You have just selected: blue, yellow``. Testing a Command which expects input ------------------------------------- diff --git a/components/console/introduction.rst b/components/console/introduction.rst index bb89cb17028..7da8fb6655a 100644 --- a/components/console/introduction.rst +++ b/components/console/introduction.rst @@ -233,7 +233,7 @@ method returns without actually printing. The MonologBridge provides a :class:`Symfony\\Bridge\\Monolog\\Handler\\ConsoleHandler` class that allows you to display messages on the console. This is cleaner than wrapping your output calls in conditions. For an example use in - the Symfony Framework, see :doc:/cookbook/logging/monolog_console. + the Symfony Framework, see :doc:`/cookbook/logging/monolog_console`. Using Command Arguments ----------------------- diff --git a/components/dependency_injection/parameters.rst b/components/dependency_injection/parameters.rst index 4265fae224c..ecf83c853b9 100644 --- a/components/dependency_injection/parameters.rst +++ b/components/dependency_injection/parameters.rst @@ -295,7 +295,7 @@ keywords (respectively ``true``, ``false`` and ``null``): .. code-block:: xml - false + false + + + + + + @AcmeFooBundle/Resources/public/js/thirdparty/jquery.js + @AcmeFooBundle/Resources/public/js/thirdparty/jquery.ui.js + + + + + .. code-block:: php + + // app/config/config.php + $container->loadFromExtension('assetic', array( + 'assets' => array( + 'jquery_and_ui' => array( + 'inputs' => array( + '@AcmeFooBundle/Resources/public/js/thirdparty/jquery.js', + '@AcmeFooBundle/Resources/public/js/thirdparty/jquery.ui.js', + ), + ), + ), + ); + +After you have defined the named assets, you can reference them in your templates +with the ``@named_asset`` notation: + +.. configuration-block:: + + .. code-block:: html+jinja + + {% javascripts + '@jquery_and_ui' + '@AcmeFooBundle/Resources/public/js/*' %} + + {% endjavascripts %} + + .. code-block:: html+php + + javascripts( + array( + '@jquery_and_ui', + '@AcmeFooBundle/Resources/public/js/*', + ) + ) as $url): ?> + + + .. _cookbook-assetic-filters: Filters diff --git a/cookbook/cache/varnish.rst b/cookbook/cache/varnish.rst index e72612acff6..48eb43c2592 100644 --- a/cookbook/cache/varnish.rst +++ b/cookbook/cache/varnish.rst @@ -19,7 +19,7 @@ As seen previously, Symfony2 is smart enough to detect whether it talks to a reverse proxy that understands ESI or not. It works out of the box when you use the Symfony2 reverse proxy, but you need a special configuration to make it work with Varnish. Thankfully, Symfony2 relies on yet another standard -written by Akamaï (`Edge Architecture`_), so the configuration tips in this +written by Akamai (`Edge Architecture`_), so the configuration tips in this chapter can be useful even if you don't use Symfony2. .. note:: diff --git a/cookbook/doctrine/registration_form.rst b/cookbook/doctrine/registration_form.rst index e61f6febbca..b3f6050e41b 100644 --- a/cookbook/doctrine/registration_form.rst +++ b/cookbook/doctrine/registration_form.rst @@ -272,7 +272,7 @@ the validation and saves the data into the database:: public function createAction(Request $request) { - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $form = $this->createForm(new RegistrationType(), new Registration()); diff --git a/cookbook/form/form_customization.rst b/cookbook/form/form_customization.rst index 52e82cc89da..92732d55695 100644 --- a/cookbook/form/form_customization.rst +++ b/cookbook/form/form_customization.rst @@ -24,7 +24,7 @@ method: .. code-block:: php - row($form['age']) }} ?> + row($form['age']); ?> You can also render each of the three parts of the field individually: diff --git a/cookbook/security/api_key_authentication.rst b/cookbook/security/api_key_authentication.rst index 3b9fbe2558f..c412bd234d6 100644 --- a/cookbook/security/api_key_authentication.rst +++ b/cookbook/security/api_key_authentication.rst @@ -38,7 +38,7 @@ value and then a User object is created:: { protected $userProvider; - public function __construct(ApiKeyUserProviderInterface $userProvider) + public function __construct(ApiKeyUserProvider $userProvider) { $this->userProvider = $userProvider; } @@ -59,7 +59,7 @@ value and then a User object is created:: public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey) { $apiKey = $token->getCredentials(); - $username = $this->userProvider->getUsernameForApiKey($apiKey) + $username = $this->userProvider->getUsernameForApiKey($apiKey); if (!$username) { throw new AuthenticationException( diff --git a/cookbook/templating/PHP.rst b/cookbook/templating/PHP.rst index 72a815af54b..382c92aa1d9 100644 --- a/cookbook/templating/PHP.rst +++ b/cookbook/templating/PHP.rst @@ -54,7 +54,10 @@ below renders the ``index.html.php`` template:: // ... public function indexAction($name) { - return $this->render('AcmeHelloBundle:Hello:index.html.php', array('name' => $name)); + return $this->render( + 'AcmeHelloBundle:Hello:index.html.php', + array('name' => $name) + ); } You can also use the :doc:`/bundles/SensioFrameworkExtraBundle/annotations/view` diff --git a/cookbook/templating/namespaced_paths.rst b/cookbook/templating/namespaced_paths.rst index 97168b74ab5..398ca058b24 100644 --- a/cookbook/templating/namespaced_paths.rst +++ b/cookbook/templating/namespaced_paths.rst @@ -77,4 +77,4 @@ called ``sidebar.twig`` in that directory, you can use it easily: .. code-block:: jinja - {% include '@foo_bar/side.bar.twig' %} + {% include '@foo_bar/sidebar.twig' %} diff --git a/cookbook/validation/custom_constraint.rst b/cookbook/validation/custom_constraint.rst index c8494cdfbc4..4bdffc45e0c 100644 --- a/cookbook/validation/custom_constraint.rst +++ b/cookbook/validation/custom_constraint.rst @@ -65,7 +65,10 @@ The validator class is also simple, and only has one required method ``validate( public function validate($value, Constraint $constraint) { if (!preg_match('/^[a-zA-Za0-9]+$/', $value, $matches)) { - $this->context->addViolation($constraint->message, array('%string%' => $value)); + $this->context->addViolation( + $constraint->message, + array('%string%' => $value) + ); } } } @@ -216,7 +219,12 @@ With this, the validator ``validate()`` method gets an object as its first argum public function validate($protocol, Constraint $constraint) { if ($protocol->getFoo() != $protocol->getBar()) { - $this->context->addViolationAt('foo', $constraint->message, array(), null); + $this->context->addViolationAt( + 'foo', + $constraint->message, + array(), + null + ); } } } diff --git a/reference/forms/types/button.rst b/reference/forms/types/button.rst index 18cbbd3103f..d688598008a 100644 --- a/reference/forms/types/button.rst +++ b/reference/forms/types/button.rst @@ -18,7 +18,7 @@ A simple, non-responsive button. | | - `label_attr`_ | | | - `translation_domain`_ | +----------------------+----------------------------------------------------------------------+ -| Overridden Options | - `auto_initialize` | +| Overridden options | - `auto_initialize`_ | +----------------------+----------------------------------------------------------------------+ | Parent type | none | +----------------------+----------------------------------------------------------------------+ diff --git a/reference/forms/types/checkbox.rst b/reference/forms/types/checkbox.rst index 159ef755c30..aeefb915ccf 100644 --- a/reference/forms/types/checkbox.rst +++ b/reference/forms/types/checkbox.rst @@ -13,9 +13,11 @@ if the box is unchecked, the value will be set to false. +-------------+------------------------------------------------------------------------+ | Options | - `value`_ | +-------------+------------------------------------------------------------------------+ +| Overridden | - `empty_data`_ | +| options | - `compound`_ | ++-------------+------------------------------------------------------------------------+ | Inherited | - `data`_ | -| options | - `empty_data`_ | -| | - `required`_ | +| options | - `required`_ | | | - `label`_ | | | - `label_attr`_ | | | - `read_only`_ | @@ -44,6 +46,13 @@ Field Options .. include:: /reference/forms/types/options/value.rst.inc +Overridden options +------------------ + +.. include:: /reference/forms/types/options/checkbox_empty_data.rst.inc + +.. include:: /reference/forms/types/options/checkbox_compound.rst.inc + Inherited options ----------------- diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index b69e48c32ed..c60b2f29f55 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -20,18 +20,20 @@ option. | | - `preferred_choices`_ | | | - `empty_value`_ | +-------------+------------------------------------------------------------------------------+ +| Overridden | - `empty_data`_ | +| options | - `compound`_ | +| | - `error_bubbling`_ | ++-------------+------------------------------------------------------------------------------+ | Inherited | - `required`_ | | options | - `label`_ | | | - `label_attr`_ | | | - `data`_ | | | - `read_only`_ | | | - `disabled`_ | -| | - `error_bubbling`_ | | | - `error_mapping`_ | | | - `mapped`_ | | | - `inherit_data`_ | | | - `by_reference`_ | -| | - `empty_data`_ | +-------------+------------------------------------------------------------------------------+ | Parent type | :doc:`form ` | +-------------+------------------------------------------------------------------------------+ @@ -109,6 +111,27 @@ can be created to supply the choices. .. include:: /reference/forms/types/options/empty_value.rst.inc +Overridden options +------------------ + +.. include:: /reference/forms/types/options/empty_data.rst.inc + +compound +~~~~~~~~ + +**type**: ``boolean`` **default**: same value as ``expanded`` option + +This option specifies if a form is compound. The value is by default +overriden by the value of the ``expanded`` option. + +error_bubbling +~~~~~~~~~~~~~~ + +**type**: ``boolean`` **default**: ``false`` + +Set that error on this field must be attached to the field instead of +the parent field (the form in most cases). + Inherited options ----------------- @@ -126,8 +149,6 @@ These options inherit from the :doc:`form ` type: .. include:: /reference/forms/types/options/disabled.rst.inc -.. include:: /reference/forms/types/options/error_bubbling.rst.inc - .. include:: /reference/forms/types/options/error_mapping.rst.inc .. include:: /reference/forms/types/options/mapped.rst.inc @@ -135,5 +156,3 @@ These options inherit from the :doc:`form ` type: .. include:: /reference/forms/types/options/inherit_data.rst.inc .. include:: /reference/forms/types/options/by_reference.rst.inc - -.. include:: /reference/forms/types/options/empty_data.rst.inc diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index dca2d76660f..76f91580dc8 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -29,6 +29,7 @@ forms, which is useful when creating forms that expose one-to-many relationships | | - `empty_data`_ | | | - `required`_ | | | - `mapped`_ | +| | - `cascade_validation`_ | +-------------+-----------------------------------------------------------------------------+ | Parent type | :doc:`form ` | +-------------+-----------------------------------------------------------------------------+ @@ -377,3 +378,5 @@ error_bubbling .. include:: /reference/forms/types/options/required.rst.inc .. include:: /reference/forms/types/options/mapped.rst.inc + +.. include:: /reference/forms/type/options/cascade_validation.rst.inc diff --git a/reference/forms/types/form.rst b/reference/forms/types/form.rst index 43ab188086a..70d78cb2788 100644 --- a/reference/forms/types/form.rst +++ b/reference/forms/types/form.rst @@ -45,8 +45,6 @@ on all fields. .. include:: /reference/forms/types/options/max_length.rst.inc -.. include:: /reference/forms/types/options/empty_data.rst.inc - .. include:: /reference/forms/types/options/by_reference.rst.inc .. include:: /reference/forms/types/options/error_bubbling.rst.inc diff --git a/reference/forms/types/options/checkbox_compound.rst.inc b/reference/forms/types/options/checkbox_compound.rst.inc new file mode 100644 index 00000000000..855969d870c --- /dev/null +++ b/reference/forms/types/options/checkbox_compound.rst.inc @@ -0,0 +1,8 @@ +compound +~~~~~~~~ + +**type**: ``boolean`` **default**: ``false`` + +This option specifies if a form is compound. As it's not the +case for checkbox, by fefault the value is overriden with +``false`` value. diff --git a/reference/forms/types/options/checkbox_empty_data.rst.inc b/reference/forms/types/options/checkbox_empty_data.rst.inc new file mode 100644 index 00000000000..8143ad364ce --- /dev/null +++ b/reference/forms/types/options/checkbox_empty_data.rst.inc @@ -0,0 +1,9 @@ +empty_data +~~~~~~~~~~ + +**type**: ``string`` **default**: ``mixed`` + +This option determines what value the field will return when the ``empty_value`` +choice is selected. +In checkbox, the value of ``empty_data`` is overriden by the value returned by +the data transformer (see :doc:`/cookbook/form/data_transformers.rst`).