From 89849c228ef579bb56dcee8962d4e9dbd6419bc6 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 15 Dec 2013 14:24:39 +0100 Subject: [PATCH 01/17] fix code block syntax --- book/validation.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book/validation.rst b/book/validation.rst index 8809fa60be8..6d9a314fc2e 100644 --- a/book/validation.rst +++ b/book/validation.rst @@ -115,7 +115,7 @@ The job of the ``validator`` is easy: to read the constraints (i.e. rules) of a class and verify whether or not the data on the object satisfies those constraints. If validation fails, a non-empty list of errors (class :class:`Symfony\\Component\\Validator\\ConstraintViolationList`) is -returned. Take this simple example from inside a controller: +returned. Take this simple example from inside a controller:: // ... use Symfony\Component\HttpFoundation\Response; @@ -169,7 +169,7 @@ You could also pass the collection of errors into a template. return $this->render('AcmeBlogBundle:Author:validate.html.twig', array( 'errors' => $errors, )); - } + } Inside the template, you can output the list of errors exactly as needed: From 4620e26a98a0407ccef1217f74f367f8abbaec83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pior?= Date: Sun, 15 Dec 2013 16:41:44 +0100 Subject: [PATCH 02/17] [#2963] Disabling validation corectly --- book/forms.rst | 11 +++----- cookbook/form/dynamic_form_modification.rst | 30 +++++++++++++++++++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/book/forms.rst b/book/forms.rst index 339e886a6d3..ef3eaa1cdf4 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -479,12 +479,10 @@ Disabling Validation .. versionadded:: 2.3 The ability to set ``validation_groups`` to false was added in Symfony 2.3, although setting it to an empty array achieved the same result in previous - versions. + versions. Please note that empty array doesn't work anymore. Sometimes it is useful to suppress the validation of a form altogether. For -these cases, you can skip the call to :method:`Symfony\\Component\\Form\\FormInterface::isValid` -in your controller. If this is not possible, you can alternatively set the -``validation_groups`` option to ``false`` or an empty array:: +these cases you can set the ``validation_groups`` option to ``false``:: use Symfony\Component\OptionsResolver\OptionsResolverInterface; @@ -497,9 +495,8 @@ in your controller. If this is not possible, you can alternatively set the Note that when you do that, the form will still run basic integrity checks, for example whether an uploaded file was too large or whether non-existing -fields were submitted. If you want to suppress validation completely, remove -the :method:`Symfony\\Component\\Form\\FormInterface::isValid` call from your -controller. +fields were submitted. If you want to surppress validation you can use +:ref:`POST_SUBMIT event ` .. index:: single: Forms; Validation groups based on submitted data diff --git a/cookbook/form/dynamic_form_modification.rst b/cookbook/form/dynamic_form_modification.rst index 68c5e98d663..f9b6824ef7a 100644 --- a/cookbook/form/dynamic_form_modification.rst +++ b/cookbook/form/dynamic_form_modification.rst @@ -535,3 +535,33 @@ after the sport is selected. This should be handled by making an AJAX call back to your application. In that controller, you can submit your form, but instead of processing it, simply use the submitted form to render the updated fields. The response from the AJAX call can then be used to update the view. + +.. _cookbook-dynamic-form-modification-supressing-form-validation: + +Supressing Form Validation +--------------------------- + +One way you can use ``POST_SUBMIT`` event is to completely supress +form validation. The reason for that is even if you set ``group_validation`` +to ``false`` there still some integrity check are run, for example whether +an uploaded file was too large or whether non-existing fields were submitted. + +If you want to suppress even that, you should use ``POST_SUBMIT`` event to prevent +:class:`Symfony\\Component\\Form\\Extension\\Validator\\EventListener\\ValidationListener` +invocation:: + + use Symfony\Component\Form\FormBuilderInterface; + use Symfony\Component\Form\FormEvents; + + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->addEventListener(FormEvents::POST_SUBMIT, function($event) { + $event->stopPropagation(); + }, /* priority higher than ValidationListener */ 200); + + // ... + } + +Note that that by doing that you can disable something more than form validation, +because ``POST_SUBMIT`` event can be used for something else. +You also have to know what would be the right priority for disabling POST_SUBMIT events. From 68d0ee24e8af502ff8042ef29707db463a057f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pior?= Date: Sun, 15 Dec 2013 21:10:11 +0100 Subject: [PATCH 03/17] Corrected docs according to WouterJ comments --- book/forms.rst | 4 ++-- cookbook/form/dynamic_form_modification.rst | 26 ++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/book/forms.rst b/book/forms.rst index ef3eaa1cdf4..87372d0f637 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -495,8 +495,8 @@ these cases you can set the ``validation_groups`` option to ``false``:: Note that when you do that, the form will still run basic integrity checks, for example whether an uploaded file was too large or whether non-existing -fields were submitted. If you want to surppress validation you can use -:ref:`POST_SUBMIT event ` +fields were submitted. If you want to suppress validation, you can use the +:ref:`POST_SUBMIT event ` .. index:: single: Forms; Validation groups based on submitted data diff --git a/cookbook/form/dynamic_form_modification.rst b/cookbook/form/dynamic_form_modification.rst index f9b6824ef7a..ccaa992e8a4 100644 --- a/cookbook/form/dynamic_form_modification.rst +++ b/cookbook/form/dynamic_form_modification.rst @@ -536,19 +536,18 @@ back to your application. In that controller, you can submit your form, but instead of processing it, simply use the submitted form to render the updated fields. The response from the AJAX call can then be used to update the view. -.. _cookbook-dynamic-form-modification-supressing-form-validation: +.. _cookbook-dynamic-form-modification-suppressing-form-validation: -Supressing Form Validation +Suppressing Form Validation --------------------------- -One way you can use ``POST_SUBMIT`` event is to completely supress -form validation. The reason for that is even if you set ``group_validation`` -to ``false`` there still some integrity check are run, for example whether -an uploaded file was too large or whether non-existing fields were submitted. +To suppress form validation you can use the ``POST_SUBMIT`` event and prevent +:class:`Symfony\\Component\\Form\\Extension\\Validator\\EventListener\\ValidationListener` +invocation. -If you want to suppress even that, you should use ``POST_SUBMIT`` event to prevent -:class:`Symfony\\Component\\Form\\Extension\\Validator\\EventListener\\ValidationListener` -invocation:: +The reason for this is even if you set ``group_validation`` to ``false`` there +are still some integrity checks executed, for example whether an uploaded file +was too large or whether non-existing fields were submitted:: use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormEvents; @@ -557,11 +556,12 @@ invocation:: { $builder->addEventListener(FormEvents::POST_SUBMIT, function($event) { $event->stopPropagation(); - }, /* priority higher than ValidationListener */ 200); + }, /* priority higher than ValidationListener */ 900); // ... } -Note that that by doing that you can disable something more than form validation, -because ``POST_SUBMIT`` event can be used for something else. -You also have to know what would be the right priority for disabling POST_SUBMIT events. +.. caution:: + + By doing this, you can disable something more than just form validation, + because ``POST_SUBMIT`` event can be used for something else. From 3909762c98ea86e44d149023ad401cbbb2862dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pior?= Date: Sun, 15 Dec 2013 21:28:26 +0100 Subject: [PATCH 04/17] One more correction --- book/forms.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/book/forms.rst b/book/forms.rst index 87372d0f637..cf45ee81d03 100644 --- a/book/forms.rst +++ b/book/forms.rst @@ -477,9 +477,7 @@ Disabling Validation ~~~~~~~~~~~~~~~~~~~~ .. versionadded:: 2.3 - The ability to set ``validation_groups`` to false was added in Symfony 2.3, - although setting it to an empty array achieved the same result in previous - versions. Please note that empty array doesn't work anymore. + The ability to set ``validation_groups`` to false was added in Symfony 2.3. Sometimes it is useful to suppress the validation of a form altogether. For these cases you can set the ``validation_groups`` option to ``false``:: From 5546fc24828bd2a9b4bb5f3f9703c2aa9516221f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 15 Dec 2013 13:55:29 +0100 Subject: [PATCH 05/17] documentation for configuring the profiler storage --- cookbook/map.rst.inc | 1 + cookbook/profiler/index.rst | 1 + cookbook/profiler/storage.rst | 69 +++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 cookbook/profiler/storage.rst diff --git a/cookbook/map.rst.inc b/cookbook/map.rst.inc index 9c8260fd929..5a5c830c49e 100644 --- a/cookbook/map.rst.inc +++ b/cookbook/map.rst.inc @@ -104,6 +104,7 @@ * :doc:`/cookbook/profiler/data_collector` * :doc:`/cookbook/profiler/matchers` + * :doc:`/cookbook/profiler/storage` * :doc:`/cookbook/request/index` diff --git a/cookbook/profiler/index.rst b/cookbook/profiler/index.rst index 3900380f932..7ff3abe1982 100644 --- a/cookbook/profiler/index.rst +++ b/cookbook/profiler/index.rst @@ -6,3 +6,4 @@ Profiler data_collector matchers + storage diff --git a/cookbook/profiler/storage.rst b/cookbook/profiler/storage.rst new file mode 100644 index 00000000000..95f070393cf --- /dev/null +++ b/cookbook/profiler/storage.rst @@ -0,0 +1,69 @@ +.. index:: + single: Profiling; Storage Configuration + +Switching the Profiler Storage +============================== + +By default the profile stores the collected data in a file in the cache directory. +You can control the storage being used through the ``dsn``, ``username``, +``password`` and ``lifetime`` options. For example, the following configuration +uses MySQL as the storage for the profiler with a lifetime of one hour: + +.. configuration-block:: + + .. code-block:: yaml + + # app/config/config.yml + framework: + profiler: + dsn: "mysql:host=localhost;dbname=%database_name%" + username: "%database_user%" + password: "%database_password%" + lifetime: 3600 + + .. code-block:: xml + + + + + + + + + + .. code-block:: php + + // app/config/config.php + + // ... + $container->loadFromExtension('framework', array( + 'profiler' => array( + 'dsn' => 'mysql:host=localhost;dbname=%database_name%', + 'username' => '%database_user', + 'password' => '%database_password%', + 'lifetime' => 3600, + ), + )); + +The :doc:`HttpKernel component ` currently +supports the following profiler storage implementations: + +* :class:`Symfony\\Component\\HttpKernel\\Profiler\\FileProfilerStorage` +* :class:`Symfony\\Component\\HttpKernel\\Profiler\\MemcachedProfilerStorage` +* :class:`Symfony\\Component\\HttpKernel\\Profiler\\MemcacheProfilerStorage` +* :class:`Symfony\\Component\\HttpKernel\\Profiler\\MongoDbProfilerStorage` +* :class:`Symfony\\Component\\HttpKernel\\Profiler\\MysqlProfilerStorage` +* :class:`Symfony\\Component\\HttpKernel\\Profiler\\RedisProfilerStorage` +* :class:`Symfony\\Component\\HttpKernel\\Profiler\\SqliteProfilerStorage` From b5f6a49dcc2d971ce24ffc5828b8361d4c92b2d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pior?= Date: Sun, 15 Dec 2013 21:40:58 +0100 Subject: [PATCH 06/17] One more correction --- cookbook/form/dynamic_form_modification.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/form/dynamic_form_modification.rst b/cookbook/form/dynamic_form_modification.rst index ccaa992e8a4..bb462d79d50 100644 --- a/cookbook/form/dynamic_form_modification.rst +++ b/cookbook/form/dynamic_form_modification.rst @@ -564,4 +564,4 @@ was too large or whether non-existing fields were submitted:: .. caution:: By doing this, you can disable something more than just form validation, - because ``POST_SUBMIT`` event can be used for something else. + because the ``POST_SUBMIT`` event can be used for something else too. From 9d14517fd68a313be7783f037261d8af0374a6c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pior?= Date: Sun, 15 Dec 2013 22:21:40 +0100 Subject: [PATCH 07/17] One more correction --- cookbook/form/dynamic_form_modification.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/form/dynamic_form_modification.rst b/cookbook/form/dynamic_form_modification.rst index bb462d79d50..c3e74dbaeee 100644 --- a/cookbook/form/dynamic_form_modification.rst +++ b/cookbook/form/dynamic_form_modification.rst @@ -556,7 +556,7 @@ was too large or whether non-existing fields were submitted:: { $builder->addEventListener(FormEvents::POST_SUBMIT, function($event) { $event->stopPropagation(); - }, /* priority higher than ValidationListener */ 900); + }, 900); /* priority higher than ValidationListener */ // ... } From 86802e2210af09016edc9733c666c17cef0854ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pior?= Date: Sun, 15 Dec 2013 23:07:55 +0100 Subject: [PATCH 08/17] Another correction --- cookbook/form/dynamic_form_modification.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/form/dynamic_form_modification.rst b/cookbook/form/dynamic_form_modification.rst index c3e74dbaeee..b3046390e6a 100644 --- a/cookbook/form/dynamic_form_modification.rst +++ b/cookbook/form/dynamic_form_modification.rst @@ -556,7 +556,7 @@ was too large or whether non-existing fields were submitted:: { $builder->addEventListener(FormEvents::POST_SUBMIT, function($event) { $event->stopPropagation(); - }, 900); /* priority higher than ValidationListener */ + }, 900); // Always set a higher priority than ValidationListener // ... } From 50f89f98d86606a35c87a966eb6e2541c8245ee8 Mon Sep 17 00:00:00 2001 From: Philipp Rieber Date: Mon, 16 Dec 2013 06:23:29 +0100 Subject: [PATCH 09/17] fix literal formatting --- book/http_cache.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/http_cache.rst b/book/http_cache.rst index b84b6a534db..811684ce2bd 100644 --- a/book/http_cache.rst +++ b/book/http_cache.rst @@ -385,7 +385,7 @@ header when none is set by the developer by following these rules: * If ``Cache-Control`` is empty (but one of the other cache headers is present), its value is set to ``private, must-revalidate``; -* But if at least one ``Cache-Control`` directive is set, and no 'public' or +* But if at least one ``Cache-Control`` directive is set, and no ``public`` or ``private`` directives have been explicitly added, Symfony2 adds the ``private`` directive automatically (except when ``s-maxage`` is set). From 752585ad80d9146f911396406ffecb6f87d3a038 Mon Sep 17 00:00:00 2001 From: Philipp Rieber Date: Mon, 16 Dec 2013 06:37:35 +0100 Subject: [PATCH 10/17] [Cookbook][Security] Use uppercase SQL keywords in query --- cookbook/security/entity_provider.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cookbook/security/entity_provider.rst b/cookbook/security/entity_provider.rst index 4901510d418..0823b56b84b 100644 --- a/cookbook/security/entity_provider.rst +++ b/cookbook/security/entity_provider.rst @@ -200,7 +200,7 @@ user records and encode their password, see :ref:`book-security-encoding-user-pa .. code-block:: bash - $ mysql> select * from acme_users; + $ mysql> SELECT * FROM acme_users; +----+----------+------+------------------------------------------+--------------------+-----------+ | id | username | salt | password | email | is_active | +----+----------+------+------------------------------------------+--------------------+-----------+ @@ -649,14 +649,14 @@ this: .. code-block:: bash - $ mysql> select * from acme_role; + $ mysql> SELECT * FROM acme_role; +----+-------+------------+ | id | name | role | +----+-------+------------+ | 1 | admin | ROLE_ADMIN | +----+-------+------------+ - $ mysql> select * from user_role; + $ mysql> SELECT * FROM user_role; +---------+---------+ | user_id | role_id | +---------+---------+ From 3c926c20bfb5971b9af15ff53436fd8d4aa1146e Mon Sep 17 00:00:00 2001 From: Philipp Rieber Date: Mon, 16 Dec 2013 07:10:00 +0100 Subject: [PATCH 11/17] [HTTP Cache] Update HTTP Bis spec links --- book/http_cache.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book/http_cache.rst b/book/http_cache.rst index b84b6a534db..55b0a8b8b60 100644 --- a/book/http_cache.rst +++ b/book/http_cache.rst @@ -1096,6 +1096,6 @@ Learn more from the Cookbook .. _`validation model`: http://tools.ietf.org/html/rfc2616#section-13.3 .. _`RFC 2616`: http://tools.ietf.org/html/rfc2616 .. _`HTTP Bis`: http://tools.ietf.org/wg/httpbis/ -.. _`P4 - Conditional Requests`: http://tools.ietf.org/html/draft-ietf-httpbis-p4-conditional-12 -.. _`P6 - Caching: Browser and intermediary caches`: http://tools.ietf.org/html/draft-ietf-httpbis-p6-cache-12 +.. _`P4 - Conditional Requests`: http://tools.ietf.org/html/draft-ietf-httpbis-p4-conditional +.. _`P6 - Caching: Browser and intermediary caches`: http://tools.ietf.org/html/draft-ietf-httpbis-p6-cache .. _`ESI`: http://www.w3.org/TR/esi-lang From 52f171fb7919ee9560961d88c870c61beaa92cd5 Mon Sep 17 00:00:00 2001 From: Philipp Rieber Date: Mon, 16 Dec 2013 08:35:27 +0100 Subject: [PATCH 12/17] [HTTP Cache] Fix typo, improve code samples --- book/http_cache.rst | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/book/http_cache.rst b/book/http_cache.rst index b84b6a534db..28dd2e99b38 100644 --- a/book/http_cache.rst +++ b/book/http_cache.rst @@ -301,9 +301,9 @@ The ``Cache-Control`` header is unique in that it contains not one, but various pieces of information about the cacheability of a response. Each piece of information is separated by a comma: - Cache-Control: private, max-age=0, must-revalidate + Cache-Control: private, max-age=0, must-revalidate - Cache-Control: max-age=3600, must-revalidate + Cache-Control: max-age=3600, must-revalidate Symfony provides an abstraction around the ``Cache-Control`` header to make its creation more manageable:: @@ -662,7 +662,7 @@ exposing a simple and efficient pattern:: // a database or a key-value store for instance) $article = ...; - // create a Response with a ETag and/or a Last-Modified header + // create a Response with an ETag and/or a Last-Modified header $response = new Response(); $response->setETag($article->computeETag()); $response->setLastModified($article->getPublishedAt()); @@ -674,17 +674,17 @@ exposing a simple and efficient pattern:: if ($response->isNotModified($this->getRequest())) { // return the 304 Response immediately return $response; - } else { - // do more work here - like retrieving more data - $comments = ...; - - // or render a template with the $response you've already started - return $this->render( - 'MyBundle:MyController:article.html.twig', - array('article' => $article, 'comments' => $comments), - $response - ); } + + // do more work here - like retrieving more data + $comments = ...; + + // or render a template with the $response you've already started + return $this->render( + 'MyBundle:MyController:article.html.twig', + array('article' => $article, 'comments' => $comments), + $response + ); } When the ``Response`` is not modified, the ``isNotModified()`` automatically sets @@ -716,8 +716,6 @@ request's ``Accept-Encoding`` value. This is done by using the ``Vary`` response header, which is a comma-separated list of different headers whose values trigger a different representation of the requested resource: -.. code-block:: text - Vary: Accept-Encoding, User-Agent .. tip:: @@ -951,8 +949,9 @@ component cache will only last for 60 seconds. When using a controller reference, the ESI tag should reference the embedded action as an accessible URL so the gateway cache can fetch it independently of the rest of the page. Symfony2 takes care of generating a unique URL for any -controller reference and it is able to route them properly thanks to a -listener that must be enabled in your configuration: +controller reference and it is able to route them properly thanks to the +:class:`Symfony\\Component\\HttpKernel\\EventListener\\FragmentListener` +that must be enabled in your configuration: .. configuration-block:: @@ -1058,10 +1057,10 @@ Here is how you can configure the Symfony2 reverse proxy to support the } $response = new Response(); - if (!$this->getStore()->purge($request->getUri())) { - $response->setStatusCode(404, 'Not purged'); - } else { + if ($this->getStore()->purge($request->getUri())) { $response->setStatusCode(200, 'Purged'); + } else { + $response->setStatusCode(404, 'Not purged'); } return $response; From fe925bcae6bcbb79dc722b0649164f5c1d22e0e9 Mon Sep 17 00:00:00 2001 From: Philipp Rieber Date: Mon, 16 Dec 2013 12:24:15 +0100 Subject: [PATCH 13/17] Fix text block inconsistency --- book/http_cache.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/book/http_cache.rst b/book/http_cache.rst index 28dd2e99b38..bdedb5b3135 100644 --- a/book/http_cache.rst +++ b/book/http_cache.rst @@ -301,6 +301,8 @@ The ``Cache-Control`` header is unique in that it contains not one, but various pieces of information about the cacheability of a response. Each piece of information is separated by a comma: +.. code-block:: text + Cache-Control: private, max-age=0, must-revalidate Cache-Control: max-age=3600, must-revalidate @@ -716,6 +718,8 @@ request's ``Accept-Encoding`` value. This is done by using the ``Vary`` response header, which is a comma-separated list of different headers whose values trigger a different representation of the requested resource: +.. code-block:: text + Vary: Accept-Encoding, User-Agent .. tip:: From 05791bb0cb0a75bb7e36e98a8a0eec79426e02de Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 26 Dec 2013 14:06:03 -0500 Subject: [PATCH 14/17] [#3344] Minor tweak --- cookbook/profiler/storage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/profiler/storage.rst b/cookbook/profiler/storage.rst index 95f070393cf..ca3c5b40c7c 100644 --- a/cookbook/profiler/storage.rst +++ b/cookbook/profiler/storage.rst @@ -4,7 +4,7 @@ Switching the Profiler Storage ============================== -By default the profile stores the collected data in a file in the cache directory. +By default the profile stores the collected data in files in the cache directory. You can control the storage being used through the ``dsn``, ``username``, ``password`` and ``lifetime`` options. For example, the following configuration uses MySQL as the storage for the profiler with a lifetime of one hour: From ef15e318b5ec153ec3723123b696374a4b09c7ac Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Thu, 26 Dec 2013 14:11:26 -0500 Subject: [PATCH 15/17] [#3346] Minor tweaks --- cookbook/form/dynamic_form_modification.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cookbook/form/dynamic_form_modification.rst b/cookbook/form/dynamic_form_modification.rst index 091c9b01c76..7af64ecd09f 100644 --- a/cookbook/form/dynamic_form_modification.rst +++ b/cookbook/form/dynamic_form_modification.rst @@ -599,12 +599,14 @@ Suppressing Form Validation --------------------------- To suppress form validation you can use the ``POST_SUBMIT`` event and prevent -:class:`Symfony\\Component\\Form\\Extension\\Validator\\EventListener\\ValidationListener` -invocation. +the :class:`Symfony\\Component\\Form\\Extension\\Validator\\EventListener\\ValidationListener` +from being called. -The reason for this is even if you set ``group_validation`` to ``false`` there -are still some integrity checks executed, for example whether an uploaded file -was too large or whether non-existing fields were submitted:: +The reason for needing to do this is that even if you set ``group_validation`` +to ``false`` there are still some integrity checks executed. For example +an uploaded file will still be checked to see if it is too large and the form +will still check to see if non-existing fields were submitted. To disable +all of this, use a listener:: use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormEvents; @@ -620,5 +622,5 @@ was too large or whether non-existing fields were submitted:: .. caution:: - By doing this, you can disable something more than just form validation, - because the ``POST_SUBMIT`` event can be used for something else too. + By doing this, you may accidentally disable something more than just form + validation, since the ``POST_SUBMIT`` event may have other listeners. From 4ef1a714acc1cb516c8624be714b77744d8f84e7 Mon Sep 17 00:00:00 2001 From: yanickj Date: Tue, 17 Dec 2013 12:04:48 -0500 Subject: [PATCH 16/17] Synchronized setter injection occurs on Container::set() not on Container::enterScope() --- cookbook/service_container/scopes.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cookbook/service_container/scopes.rst b/cookbook/service_container/scopes.rst index 8f6fd9fd34d..663636fded3 100644 --- a/cookbook/service_container/scopes.rst +++ b/cookbook/service_container/scopes.rst @@ -134,6 +134,7 @@ marked as ``synchronized``: class: Acme\HelloBundle\Client\ClientConfiguration scope: client synchronized: true + synthetic: true # ... .. code-block:: xml @@ -151,6 +152,7 @@ marked as ``synchronized``: id="client_configuration" scope="client" synchronized="true" + synthetic="true" class="Acme\HelloBundle\Client\ClientConfiguration" /> @@ -196,9 +198,9 @@ and everything works without any special code in your service or in your definit } } -Whenever the ``client`` scope is entered or left, the service container will -automatically call the ``setClientConfiguration()`` method with the current -``client_configuration`` instance. +Whenever the ``client`` scope is active, the service container will +automatically call the ``setClientConfiguration()`` method when the +``client_configuration`` service is set in the container. You might have noticed that the ``setClientConfiguration()`` method accepts ``null`` as a valid value for the ``client_configuration`` argument. That's From 0dfffffe38eea592a5bef4fccf59c0915386ae0b Mon Sep 17 00:00:00 2001 From: yanickj Date: Tue, 17 Dec 2013 13:30:59 -0500 Subject: [PATCH 17/17] Update PHP example to include synthetic attribute. --- cookbook/service_container/scopes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/cookbook/service_container/scopes.rst b/cookbook/service_container/scopes.rst index 663636fded3..59d4cd425a4 100644 --- a/cookbook/service_container/scopes.rst +++ b/cookbook/service_container/scopes.rst @@ -169,6 +169,7 @@ marked as ``synchronized``: ); $definition->setScope('client'); $definition->setSynchronized(true); + $definition->setSynthetic(true); $container->setDefinition('client_configuration', $definition); Now, if you inject this service using setter injection, there are no drawbacks