Skip to content

Commit 1f343b1

Browse files
committed
Merge branch '2.3' into 2.5
2 parents 32bd0b1 + 28571fc commit 1f343b1

File tree

8 files changed

+46
-30
lines changed

8 files changed

+46
-30
lines changed

best_practices/templates.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ name is irrelevant because you never use it in your own code):
153153
app.twig.app_extension:
154154
class: AppBundle\Twig\AppExtension
155155
arguments: ["@markdown"]
156-
public: false
156+
public: false
157157
tags:
158158
- { name: twig.extension }
159159

book/forms.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,7 @@ an array.
18541854
You can also access POST values (in this case "name") directly through
18551855
the request object, like so::
18561856

1857-
$this->get('request')->request->get('name');
1857+
$request->request->get('name');
18581858

18591859
Be advised, however, that in most cases using the ``getData()`` method is
18601860
a better choice, since it returns the data (usually an object) after

book/routing.rst

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ file:
173173
<container xmlns="http://symfony.com/schema/dic/services"
174174
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
175175
xmlns:framework="http://symfony.com/schema/dic/symfony"
176-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
177-
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
176+
xsi:schemaLocation="http://symfony.com/schema/dic/services
177+
http://symfony.com/schema/dic/services/services-1.0.xsd
178+
http://symfony.com/schema/dic/symfony
179+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
178180
179181
<framework:config>
180182
<!-- ... -->
@@ -649,7 +651,9 @@ be added for each parameter. For example:
649651
// ...
650652
651653
/**
652-
* @Route("/blog/{page}", defaults={"page": 1}, requirements={"page": "\d+"})
654+
* @Route("/blog/{page}", defaults={"page": 1}, requirements={
655+
* "page": "\d+"
656+
* })
653657
*/
654658
public function indexAction($page)
655659
{
@@ -737,7 +741,9 @@ URL:
737741
class MainController extends Controller
738742
{
739743
/**
740-
* @Route("/{_locale}", defaults={"_locale": "en"}, requirements={"_locale": "en|fr"})
744+
* @Route("/{_locale}", defaults={"_locale": "en"}, requirements={
745+
* "_locale": "en|fr"
746+
* })
741747
*/
742748
public function homepageAction($_locale)
743749
{
@@ -1018,8 +1024,12 @@ routing system can be:
10181024
/**
10191025
* @Route(
10201026
* "/articles/{_locale}/{year}/{title}.{_format}",
1021-
* defaults: {"_format": "html"}
1022-
* requirements: {"_locale": "en|fr", "_format": "html|rss", "year": "\d+"}
1027+
* defaults: {"_format": "html"},
1028+
* requirements: {
1029+
* "_locale": "en|fr",
1030+
* "_format": "html|rss",
1031+
* "year": "\d+"
1032+
* }
10231033
* )
10241034
*/
10251035
public function showAction($_locale, $year, $title)
@@ -1096,7 +1106,7 @@ a slash. URLs matching this route might look like:
10961106
This example also highlights the special ``_format`` routing parameter.
10971107
When using this parameter, the matched value becomes the "request format"
10981108
of the ``Request`` object. Ultimately, the request format is used for such
1099-
things such as setting the ``Content-Type`` of the response (e.g. a ``json``
1109+
things as setting the ``Content-Type`` of the response (e.g. a ``json``
11001110
request format translates into a ``Content-Type`` of ``application/json``).
11011111
It can also be used in the controller to render a different template for
11021112
each value of ``_format``. The ``_format`` parameter is a very powerful way
@@ -1188,7 +1198,7 @@ each is made available as an argument to the controller method::
11881198

11891199
public function showAction($slug)
11901200
{
1191-
// ...
1201+
// ...
11921202
}
11931203

11941204
In reality, the entire ``defaults`` collection is merged with the parameter
@@ -1263,8 +1273,8 @@ configuration:
12631273
12641274
$collection = new RouteCollection();
12651275
$collection->addCollection(
1266-
// second argument is the type, which is required to enable the annotation reader
1267-
// for this resource
1276+
// second argument is the type, which is required to enable
1277+
// the annotation reader for this resource
12681278
$loader->import("@AppBundle/Controller/", "annotation")
12691279
);
12701280
@@ -1354,7 +1364,7 @@ suppose you want to prefix all routes in the AppBundle with ``/site`` (e.g.
13541364
// app/config/routing.php
13551365
use Symfony\Component\Routing\RouteCollection;
13561366
1357-
$app = $loader->import('@AppBundle/Controller/');
1367+
$app = $loader->import('@AppBundle/Controller/', 'annotation');
13581368
$app->addPrefix('/site');
13591369
13601370
$collection = new RouteCollection();
@@ -1437,7 +1447,9 @@ system. Take the ``blog_show`` example route from earlier::
14371447
// '_controller' => 'AppBundle:Blog:show',
14381448
// )
14391449

1440-
$uri = $this->get('router')->generate('blog_show', array('slug' => 'my-blog-post'));
1450+
$uri = $this->get('router')->generate('blog_show', array(
1451+
'slug' => 'my-blog-post'
1452+
));
14411453
// /blog/my-blog-post
14421454

14431455
To generate a URL, you need to specify the name of the route (e.g. ``blog_show``)
@@ -1505,7 +1517,10 @@ Generating URLs with Query Strings
15051517
The ``generate`` method takes an array of wildcard values to generate the URI.
15061518
But if you pass extra ones, they will be added to the URI as a query string::
15071519

1508-
$this->get('router')->generate('blog', array('page' => 2, 'category' => 'Symfony'));
1520+
$this->get('router')->generate('blog', array(
1521+
'page' => 2,
1522+
'category' => 'Symfony'
1523+
));
15091524
// /blog/2?category=Symfony
15101525

15111526
Generating URLs from a Template
@@ -1546,7 +1561,7 @@ method::
15461561

15471562
From a template, in Twig, simply use the ``url()`` function (which generates an absolute URL)
15481563
rather than the ``path()`` function (which generates a relative URL). In PHP, pass ``true``
1549-
to ``generateUrl()``:
1564+
to ``generate()``:
15501565

15511566
.. configuration-block::
15521567

book/security.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ user to be logged in to access this URL:
209209
# ...
210210
firewalls:
211211
# ...
212-
212+
213213
access_control:
214214
# require ROLE_ADMIN for /admin*
215215
- { path: ^/admin, roles: ROLE_ADMIN }
@@ -432,9 +432,10 @@ If you'd like to load your users via the Doctrine ORM, that's easy! See
432432
:doc:`/cookbook/security/entity_provider` for all the details.
433433

434434
.. _book-security-encoding-user-password:
435+
.. _c-encoding-the-users-password:
435436

436-
C) Encoding the Users Password
437-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
437+
C) Encoding the User's Password
438+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
438439

439440
Whether your users are stored in ``security.yml``, in a database or somewhere
440441
else, you'll want to encode their passwords. The best algorithm to use is
@@ -676,7 +677,7 @@ URL pattern. You saw this earlier, where anything matching the regular expressio
676677
# ...
677678
firewalls:
678679
# ...
679-
680+
680681
access_control:
681682
# require ROLE_ADMIN for /admin*
682683
- { path: ^/admin, roles: ROLE_ADMIN }
@@ -867,9 +868,9 @@ in this chapter).
867868
Be careful with this in your layout or on your error pages! Because of
868869
some internal Symfony details, to avoid broken error pages in the ``prod``
869870
environment, wrap calls in these templates with a check for ``app.user``:
870-
871+
871872
.. code-block:: html+jinja
872-
873+
873874
{% if app.user and is_granted('ROLE_ADMIN') %}
874875

875876
Securing other Services
@@ -1029,7 +1030,7 @@ the User object, and use the ``isGranted`` method (or
10291030

10301031
// boo :(. Never check for the User object to see if they're logged in
10311032
if ($this->getUser()) {
1032-
1033+
10331034
}
10341035

10351036
Retrieving the User in a Template
@@ -1048,7 +1049,7 @@ key:
10481049

10491050
.. code-block:: html+php
10501051

1051-
<?php if ($view['security']->isGranted('IS_AUTHENTICATED_FULLY')): ?>
1052+
<?php if ($view['security']->isGranted('IS_AUTHENTICATED_FULLY')): ?>
10521053
<p>Username: <?php echo $app->getUser()->getUsername() ?></p>
10531054
<?php endif; ?>
10541055

book/validation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,8 @@ the string ``Default``.
847847
If you have inheritance (e.g. ``User extends BaseUser``) and you validate
848848
with the class name of the subclass (i.e. ``User``), then all constraints
849849
in the ``User`` and ``BaseUser`` will be validated. However, if you validate
850-
using the base class (i.e. ``BaseUser``), then only the constraints in
851-
the ``BaseUser`` group will be validated.
850+
using the base class (i.e. ``BaseUser``), then only the default constraints in
851+
the ``BaseUser`` class will be validated.
852852

853853
To tell the validator to use a specific group, pass one or more group names
854854
as the third argument to the ``validate()`` method::

components/config/definition.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,8 @@ Otherwise the result is a clean array of configuration values::
566566
use Symfony\Component\Config\Definition\Processor;
567567
use Acme\DatabaseConfiguration;
568568

569-
$config1 = Yaml::parse(__DIR__.'/src/Matthias/config/config.yml');
570-
$config2 = Yaml::parse(__DIR__.'/src/Matthias/config/config_extra.yml');
569+
$config1 = Yaml::parse(file_get_contents(__DIR__.'/src/Matthias/config/config.yml'));
570+
$config2 = Yaml::parse(file_get_contents(__DIR__.'/src/Matthias/config/config_extra.yml'));
571571

572572
$configs = array($config1, $config2);
573573

components/config/resources.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class, which allows for recursively importing other resources::
3939
{
4040
public function load($resource, $type = null)
4141
{
42-
$configValues = Yaml::parse($resource);
42+
$configValues = Yaml::parse(file_get_contents($resource));
4343

4444
// ... handle the config values
4545

components/serializer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ When serializing, you can set a callback to format a specific object property::
224224
return $dateTime instanceof \DateTime
225225
? $dateTime->format(\DateTime::ISO8601)
226226
: '';
227-
}
227+
};
228228

229229
$normalizer->setCallbacks(array('createdAt' => $callback));
230230

0 commit comments

Comments
 (0)