Skip to content

Commit

Permalink
Merge branch '2.7' into 2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Aug 23, 2015
2 parents 7f05db4 + ec522d9 commit 84e2495
Show file tree
Hide file tree
Showing 53 changed files with 501 additions and 480 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/_build
/_exts
*.pyc
2 changes: 1 addition & 1 deletion best_practices/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ makes them easier to re-use later.

Add buttons in the templates, not in the form classes or the controllers.

Since Symfony 2.5, you can add buttons as fields on your form. This is a nice
Since Symfony 2.3, you can add buttons as fields on your form. This is a nice
way to simplify the template that renders your form. But if you add the buttons
directly in your form class, this would effectively limit the scope of that form:

Expand Down
6 changes: 4 additions & 2 deletions book/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,10 @@ covered later), group, etc. For more information, see the official
Querying for Objects Using Doctrine's Query Builder
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Instead of writing a DQL string, you can alternatively use a helpful object called
the ``QueryBuilder`` to build that string for you::
Instead of writing a DQL string, you can use a helpful object called the
``QueryBuilder`` to build that string for you. This is useful when the actual query
depends on dynamic conditions, as your code soon becomes hard to read with
DQL as you start to concatenate strings::

$repository = $this->getDoctrine()
->getRepository('AppBundle:Product');
Expand Down
8 changes: 4 additions & 4 deletions book/page_creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ at the end:
}
// ...
}
}
.. code-block:: yaml
Expand Down Expand Up @@ -272,7 +272,7 @@ easy, powerful and actually quite fun.
So far, ``LuckyController`` doesn't extend any base class. The easiest way
to use Twig - or many other tools in Symfony - is to extend Symfony's base
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller` class::

// src/AppBundle/Controller/LuckyController.php
// ...

Expand Down Expand Up @@ -566,9 +566,9 @@ Ok, time to finish mastering the fundamentals by reading these chapters:
* :doc:`/book/routing`
* :doc:`/book/templating`

Then, learn about Symfony's :doc:`service container </book/service_container>`
Then, in the :doc:`Symfony Book </book/index>`, learn about the :doc:`service container </book/service_container>`,
the :doc:`form system </book/forms>`, using :doc:`Doctrine </book/doctrine>`
if you need to query a database and more. in the :doc:`Symfony Book </book/index>`.
(if you need to query a database) and more!

There's also a :doc:`Cookbook </cookbook/index>` *packed* with more advanced
"how to" articles to solve *a lot* of problems.
Expand Down
2 changes: 1 addition & 1 deletion book/templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ is a :class:`Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables`
instance which will give you access to some application specific variables
automatically:

``app.security``
``app.security`` (deprecated as of 2.6)
The security context.
``app.user``
The current user object.
Expand Down
5 changes: 3 additions & 2 deletions book/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ expression or a CSS selector, then use the client to click on it. For example::
$link = $crawler
->filter('a:contains("Greet")') // find all links with the text "Greet"
->eq(1) // select the second link in the list
->link() // and click it
->link()
;

// and click it
$crawler = $client->click($link);

Submitting a form is very similar: select a form button, optionally override
Expand Down
2 changes: 1 addition & 1 deletion components/config/definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ All options can be documented using the
method.

The info will be printed as a comment when dumping the configuration tree
with the ``config:dump`` command.
with the ``config:dump-reference`` command.

.. versionadded:: 2.6
Since Symfony 2.6, the info will also be added to the exception message
Expand Down
2 changes: 1 addition & 1 deletion cookbook/form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ it with :ref:`dic-tags-form-type`.
<!-- app/config/config.xml -->
<services>
<service id="app.form.friend_message" class="AppBundle\Form\Type\FriendMessageFormType">
<argument type="service" id="security.context" />
<argument type="service" id="security.token_storage" />
<tag name="form.type" alias="friend_message" />
</service>
</services>
Expand Down
2 changes: 1 addition & 1 deletion cookbook/logging/channels_handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ the channel).
.. note::

Each channel corresponds to a logger service (``monolog.logger.XXX``)
in the container (use the ``container:debug`` command to see a full list)
in the container (use the ``debug:container`` command to see a full list)
and those are injected into different services.

.. _logging-channel-handler:
Expand Down
16 changes: 8 additions & 8 deletions reference/constraints/All.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ entry in that array:

.. code-block:: php-annotations
// src/Acme/UserBundle/Entity/User.php
namespace Acme\UserBundle\Entity;
// src/AppBundle/Entity/User.php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
Expand All @@ -43,8 +43,8 @@ entry in that array:
.. code-block:: yaml
# src/Acme/UserBundle/Resources/config/validation.yml
Acme\UserBundle\Entity\User:
# src/AppBundle/Resources/config/validation.yml
AppBundle\Entity\User:
properties:
favoriteColors:
- All:
Expand All @@ -54,13 +54,13 @@ entry in that array:
.. code-block:: xml
<!-- src/Acme/UserBundle/Resources/config/validation.xml -->
<!-- src/AppBundle/Resources/config/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
<class name="Acme\UserBundle\Entity\User">
<class name="AppBundle\Entity\User">
<property name="favoriteColors">
<constraint name="All">
<option name="constraints">
Expand All @@ -76,8 +76,8 @@ entry in that array:
.. code-block:: php
// src/Acme/UserBundle/Entity/User.php
namespace Acme\UserBundle\Entity;
// src/AppBundle/Entity/User.php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;
Expand Down
16 changes: 8 additions & 8 deletions reference/constraints/Blank.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ of an ``Author`` class were blank, you could do the following:

.. code-block:: php-annotations
// src/Acme/BlogBundle/Entity/Author.php
namespace Acme\BlogBundle\Entity;
// src/AppBundle/Entity/Author.php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
Expand All @@ -42,21 +42,21 @@ of an ``Author`` class were blank, you could do the following:
.. code-block:: yaml
# src/Acme/BlogBundle/Resources/config/validation.yml
Acme\BlogBundle\Entity\Author:
# src/AppBundle/Resources/config/validation.yml
AppBundle\Entity\Author:
properties:
firstName:
- Blank: ~
.. code-block:: xml
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
<!-- src/AppBundle/Resources/config/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
<class name="Acme\BlogBundle\Entity\Author">
<class name="AppBundle\Entity\Author">
<property name="firstName">
<constraint name="Blank" />
</property>
Expand All @@ -65,8 +65,8 @@ of an ``Author`` class were blank, you could do the following:
.. code-block:: php
// src/Acme/BlogBundle/Entity/Author.php
namespace Acme\BlogBundle\Entity;
// src/AppBundle/Entity/Author.php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;
Expand Down
85 changes: 50 additions & 35 deletions reference/constraints/Callback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Configuration

.. code-block:: php-annotations
// src/Acme/BlogBundle/Entity/Author.php
namespace Acme\BlogBundle\Entity;
// src/AppBundle/Entity/Author.php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
Expand All @@ -56,28 +56,28 @@ Configuration
.. code-block:: yaml
# src/Acme/BlogBundle/Resources/config/validation.yml
Acme\BlogBundle\Entity\Author:
# src/AppBundle/Resources/config/validation.yml
AppBundle\Entity\Author:
constraints:
- Callback: [validate]
.. code-block:: xml
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
<!-- src/AppBundle/Resources/config/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
<class name="Acme\BlogBundle\Entity\Author">
<class name="AppBundle\Entity\Author">
<constraint name="Callback">validate</constraint>
</class>
</constraint-mapping>
.. code-block:: php
// src/Acme/BlogBundle/Entity/Author.php
namespace Acme\BlogBundle\Entity;
// src/AppBundle/Entity/Author.php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;
Expand Down Expand Up @@ -185,57 +185,69 @@ You can then use the following configuration to invoke this validator:

.. code-block:: php-annotations
// src/Acme/BlogBundle/Entity/Author.php
// src/AppBundle/Entity/Author.php
namespace Acme\BlogBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @Assert\Callback({"Vendor\Package\Validator", "validate"})
* @Assert\Callback({"AppBundle\MyStaticValidatorClass", "isAuthorValid"})
*/
class Author
{
}
.. code-block:: yaml
# src/Acme/BlogBundle/Resources/config/validation.yml
Acme\BlogBundle\Entity\Author:
constraints:
- Callback: [Vendor\Package\Validator, validate]
# src/AppBundle/Resources/config/validation.yml
AppBundle\Entity\Author:
constraints:
- Callback:
methods:
- [AppBundle\MyStaticValidatorClass, isAuthorValid]

.. code-block:: xml
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
<class name="Acme\BlogBundle\Entity\Author">
<constraint name="Callback">
<value>Vendor\Package\Validator</value>
<value>validate</value>
</constraint>
</class>
</constraint-mapping>
<!-- src/AppBundle/Resources/config/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

<class name="AppBundle\Entity\Author">
<constraint name="Callback">
<option name="methods">
<value>
<value>AppBundle\MyStaticValidatorClass</value>
<value>isAuthorValid</value>
</value>
</option>
</constraint>
</class>
</constraint-mapping>

.. code-block:: php
// src/Acme/BlogBundle/Entity/Author.php
namespace Acme\BlogBundle\Entity;
// src/AppBundle/Entity/Author.php
namespace AppBundle\Entity;

use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;

class Author
{
public $name;

public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addConstraint(new Assert\Callback(array(
'Vendor\Package\Validator',
'validate',
)));
$metadata->addConstraint(new Callback(array(
'methods' => array(
array(
'AppBundle\MyStaticValidatorClass',
'isAuthorValid',
),
),
)));
}
}

Expand All @@ -250,8 +262,11 @@ You can then use the following configuration to invoke this validator:
When configuring the constraint via PHP, you can also pass a closure to the
constructor of the Callback constraint::

// src/Acme/BlogBundle/Entity/Author.php
namespace Acme\BlogBundle\Entity;
// src/AppBundle/Entity/Author.php
namespace AppBundle\Entity;

use Symfony\Component\Validator\ExecutionContextInterface;
use AppBundle\Entity\Author;

use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;
Expand Down
Loading

0 comments on commit 84e2495

Please sign in to comment.