Skip to content

Commit c894a66

Browse files
committed
Merge branch '2.1'
2 parents 5bc503d + 1629d49 commit c894a66

16 files changed

+304
-69
lines changed

book/doctrine.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ be.
1515

1616
Doctrine is totally decoupled from Symfony and using it is optional.
1717
This chapter is all about the Doctrine ORM, which aims to let you map
18-
objects to a relational database (such as *MySQL*, *PostgreSQL* or
19-
*Microsoft SQL*). If you prefer to use raw database queries, this is
18+
objects to a relational database (such as *MySQL*, *PostgreSQL* or
19+
*Microsoft SQL*). If you prefer to use raw database queries, this is
2020
easy, and explained in the ":doc:`/cookbook/doctrine/dbal`" cookbook entry.
2121

2222
You can also persist data to `MongoDB`_ using Doctrine ODM library. For
@@ -478,6 +478,13 @@ on its ``id`` value::
478478
// ... do something, like pass the $product object into a template
479479
}
480480

481+
.. tip::
482+
483+
You can achieve the equivalent of this without writing any code by using
484+
the ``@ParamConverter`` shortcut. See the
485+
:doc:`FrameworkExtraBundle documentation</bundles/SensioFrameworkExtraBundle/annotations/converters>`
486+
for more details.
487+
481488
When you query for a particular type of object, you always use what's known
482489
as its "repository". You can think of a repository as a PHP class whose only
483490
job is to help you fetch entities of a certain class. You can access the

book/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ first "real" Symfony2 webpage:
268268
269269
Symfony2 should welcome and congratulate you for your hard work so far!
270270

271-
.. image:: /images/quick_tour/welcome.jpg
271+
.. image:: /images/quick_tour/welcome.png
272272

273273
Beginning Development
274274
---------------------

book/routing.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,11 @@ match, giving the ``page`` parameter a value of ``2``. Perfect.
415415
| /blog/2 | {page} = 2 |
416416
+---------+------------+
417417

418+
.. tip::
419+
420+
Routes with optional parameters at the end will not match on requests
421+
with a trailing slash (i.e. ``/blog/`` will not match, ``/blog`` will match).
422+
418423
.. index::
419424
single: Routing; Requirements
420425

book/security.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,8 @@ is defined by the ``target`` parameter above (e.g. the ``homepage``). For
15991599
more information on configuring the logout, see the
16001600
:doc:`Security Configuration Reference</reference/configuration/security>`.
16011601

1602+
.. _book-security-template:
1603+
16021604
Access Control in Templates
16031605
---------------------------
16041606

book/templating.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ used to return content to the user, populate email bodies, and more. You'll
1414
learn shortcuts, clever ways to extend templates and how to reuse template
1515
code.
1616

17+
.. note::
18+
19+
How to render templates is covered in the :ref:`controller <controller-rendering-templates>`
20+
page of the book.
21+
22+
1723
.. index::
1824
single: Templating; What is a template?
1925

@@ -695,6 +701,8 @@ in your application configuration:
695701
.. index::
696702
single: Templating; Linking to pages
697703

704+
.. _book-templating-pages:
705+
698706
Linking to Pages
699707
~~~~~~~~~~~~~~~~
700708

@@ -812,6 +820,8 @@ correctly:
812820
.. index::
813821
single: Templating; Linking to assets
814822

823+
.. _book-templating-assets:
824+
815825
Linking to Assets
816826
~~~~~~~~~~~~~~~~~
817827

book/translation.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ Translations in Templates
720720
Most of the time, translation occurs in templates. Symfony2 provides native
721721
support for both Twig and PHP templates.
722722

723+
.. _book-translation-twig:
724+
723725
Twig Templates
724726
~~~~~~~~~~~~~~
725727

cookbook/security/acl.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ the ACL system comes in.
1212
Imagine you are designing a blog system where your users can comment on your
1313
posts. Now, you want a user to be able to edit his own comments, but not those
1414
of other users; besides, you yourself want to be able to edit all comments. In
15-
this scenario, ``Comment`` would be our domain object that you want to
15+
this scenario, ``Comment`` would be the domain object that you want to
1616
restrict access to. You could take several approaches to accomplish this using
1717
Symfony2, two basic approaches are (non-exhaustive):
1818

@@ -27,13 +27,13 @@ logic to your business code which makes it less reusable elsewhere, and also
2727
increases the difficulty of unit testing. Besides, you could run into
2828
performance issues if many users would have access to a single domain object.
2929

30-
Fortunately, there is a better way, which we will talk about now.
30+
Fortunately, there is a better way, which you will find out about now.
3131

3232
Bootstrapping
3333
-------------
3434

35-
Now, before we finally can get into action, we need to do some bootstrapping.
36-
First, we need to configure the connection the ACL system is supposed to use:
35+
Now, before you can finally get into action, you need to do some bootstrapping.
36+
First, you need to configure the connection the ACL system is supposed to use:
3737

3838
.. configuration-block::
3939

@@ -67,8 +67,8 @@ First, we need to configure the connection the ACL system is supposed to use:
6767
domain objects. You can use whatever mapper you like for your objects, be it
6868
Doctrine ORM, MongoDB ODM, Propel, raw SQL, etc. The choice is yours.
6969

70-
After the connection is configured, we have to import the database structure.
71-
Fortunately, we have a task for this. Simply run the following command:
70+
After the connection is configured, you have to import the database structure.
71+
Fortunately, there is a task for this. Simply run the following command:
7272

7373
.. code-block:: bash
7474
@@ -77,7 +77,7 @@ Fortunately, we have a task for this. Simply run the following command:
7777
Getting Started
7878
---------------
7979

80-
Coming back to our small example from the beginning, let's implement ACL for
80+
Coming back to the small example from the beginning, let's implement ACL for
8181
it.
8282

8383
Creating an ACL, and adding an ACE
@@ -136,11 +136,11 @@ have no actual domain object instance at hand. This will be extremely helpful
136136
if you want to check permissions for a large number of objects without
137137
actually hydrating these objects.
138138

139-
The other interesting part is the ``->insertObjectAce()`` call. In our
140-
example, we are granting the user who is currently logged in owner access to
139+
The other interesting part is the ``->insertObjectAce()`` call. In the
140+
example, you are granting the user who is currently logged in owner access to
141141
the Comment. The ``MaskBuilder::MASK_OWNER`` is a pre-defined integer bitmask;
142142
don't worry the mask builder will abstract away most of the technical details,
143-
but using this technique we can store many different permissions in one
143+
but using this technique you can store many different permissions in one
144144
database row which gives us a considerable boost in performance.
145145

146146
.. tip::
@@ -175,7 +175,7 @@ Checking Access
175175
}
176176
}
177177
178-
In this example, we check whether the user has the ``EDIT`` permission.
178+
In this example, you check whether the user has the ``EDIT`` permission.
179179
Internally, Symfony2 maps the permission to several integer bitmasks, and
180180
checks whether the user has any of them.
181181

@@ -188,10 +188,10 @@ checks whether the user has any of them.
188188
Cumulative Permissions
189189
----------------------
190190

191-
In our first example above, we only granted the user the ``OWNER`` base
191+
In the first example above, you only granted the user the ``OWNER`` base
192192
permission. While this effectively also allows the user to perform any
193193
operation such as view, edit, etc. on the domain object, there are cases where
194-
we want to grant these permissions explicitly.
194+
you may want to grant these permissions explicitly.
195195

196196
The ``MaskBuilder`` can be used for creating bit masks easily by combining
197197
several base permissions:

cookbook/security/acl_advanced.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ objectives:
2424
As indicated by the first point, one of the main capabilities of Symfony2's
2525
ACL system is a high-performance way of retrieving ACLs/ACEs. This is
2626
extremely important since each ACL might have several ACEs, and inherit from
27-
another ACL in a tree-like fashion. Therefore, we specifically do not leverage
28-
any ORM, but the default implementation interacts with your connection
29-
directly using Doctrine's DBAL.
27+
another ACL in a tree-like fashion. Therefore, no ORM is leveraged, instead
28+
the default implementation interacts with your connection directly using Doctrine's
29+
DBAL.
3030

3131
Object Identities
3232
~~~~~~~~~~~~~~~~~
@@ -71,16 +71,16 @@ Scope of Access Control Entries
7171
-------------------------------
7272

7373
Access control entries can have different scopes in which they apply. In
74-
Symfony2, we have basically two different scopes:
74+
Symfony2, there are basically two different scopes:
7575

7676
- Class-Scope: These entries apply to all objects with the same class.
77-
- Object-Scope: This was the scope we solely used in the previous chapter, and
77+
- Object-Scope: This was the scope solely used in the previous chapter, and
7878
it only applies to one specific object.
7979

8080
Sometimes, you will find the need to apply an ACE only to a specific field of
8181
the object. Let's say you want the ID only to be viewable by an administrator,
82-
but not by your customer service. To solve this common problem, we have added
83-
two more sub-scopes:
82+
but not by your customer service. To solve this common problem, two more sub-scopes
83+
have been added:
8484

8585
- Class-Field-Scope: These entries apply to all objects with the same class,
8686
but only to a specific field of the objects.
@@ -91,10 +91,10 @@ Pre-Authorization Decisions
9191
---------------------------
9292

9393
For pre-authorization decisions, that is decisions made before any secure method (or
94-
secure action) is invoked, we rely on the proven AccessDecisionManager service
95-
that is also used for reaching authorization decisions based on roles. Just
96-
like roles, the ACL system adds several new attributes which may be used to
97-
check for different permissions.
94+
secure action) is invoked, the proven AccessDecisionManager service is used.
95+
The AccessDecisionManager is also used for reaching authorization decisions based
96+
on roles. Just like roles, the ACL system adds several new attributes which may be
97+
used to check for different permissions.
9898

9999
Built-in Permission Map
100100
~~~~~~~~~~~~~~~~~~~~~~~
@@ -153,8 +153,8 @@ Extensibility
153153

154154
The above permission map is by no means static, and theoretically could be
155155
completely replaced at will. However, it should cover most problems you
156-
encounter, and for interoperability with other bundles, we encourage you to
157-
stick to the meaning we have envisaged for them.
156+
encounter, and for interoperability with other bundles, you are encouraged to
157+
stick to the meaning envisaged for them.
158158

159159
Post Authorization Decisions
160160
----------------------------

cookbook/security/custom_authentication_provider.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ The Token
4545
The role of the token in the Symfony2 security context is an important one.
4646
A token represents the user authentication data present in the request. Once
4747
a request is authenticated, the token retains the user's data, and delivers
48-
this data across the security context. First, we will create our token class.
49-
This will allow the passing of all relevant information to our authentication
48+
this data across the security context. First, you'll create your token class.
49+
This will allow the passing of all relevant information to your authentication
5050
provider.
5151

5252
.. code-block:: php
@@ -332,7 +332,7 @@ a firewall in your security configuration.
332332

333333
.. note::
334334

335-
You may be wondering "why do we need a special factory class to add listeners
335+
You may be wondering "why do you need a special factory class to add listeners
336336
and providers to the dependency injection container?". This is a very
337337
good question. The reason is you can use your firewall multiple times,
338338
to secure multiple parts of your application. Because of this, each

cookbook/security/custom_provider.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ the configured user provider to return a user object for a given username.
1010
Symfony then checks whether the password of this user is correct and generates
1111
a security token so the user stays authenticated during the current session.
1212
Out of the box, Symfony has an "in_memory" and an "entity" user provider.
13-
In this entry we'll see how you can create your own user provider, which
13+
In this entry you'll see how you can create your own user provider, which
1414
could be useful if your users are accessed via a custom database, a file,
15-
or - as we show in this example - a web service.
15+
or - as shown in this example - a web service.
1616

1717
Create a User Class
1818
-------------------
@@ -21,7 +21,7 @@ First, regardless of *where* your user data is coming from, you'll need to
2121
create a ``User`` class that represents that data. The ``User`` can look
2222
however you want and contain any data. The only requirement is that the
2323
class implements :class:`Symfony\\Component\\Security\\Core\\User\\UserInterface`.
24-
The methods in this interface should therefore be defined in the custom user
24+
The methods in this interface should therefore be defined in the custom user
2525
class: ``getRoles()``, ``getPassword()``, ``getSalt()``, ``getUsername()``,
2626
``eraseCredentials()``, ``equals()``.
2727

@@ -101,12 +101,12 @@ For more details on each of the methods, see :class:`Symfony\\Component\\Securit
101101
Create a User Provider
102102
----------------------
103103

104-
Now that we have a ``User`` class, we'll create a user provider, which will
104+
Now that you have a ``User`` class, you'll create a user provider, which will
105105
grab user information from some web service, create a ``WebserviceUser`` object,
106106
and populate it with data.
107107

108-
The user provider is just a plain PHP class that has to implement the
109-
:class:`Symfony\\Component\\Security\\Core\\User\\UserProviderInterface`,
108+
The user provider is just a plain PHP class that has to implement the
109+
:class:`Symfony\\Component\\Security\\Core\\User\\UserProviderInterface`,
110110
which requires three methods to be defined: ``loadUserByUsername($username)``,
111111
``refreshUser(UserInterface $user)``, and ``supportsClass($class)``. For
112112
more details, see :class:`Symfony\\Component\\Security\\Core\\User\\UserProviderInterface`.
@@ -158,7 +158,7 @@ Here's an example of how this might look::
158158
Create a Service for the User Provider
159159
--------------------------------------
160160

161-
Now we make the user provider available as a service.
161+
Now you make the user provider available as a service:
162162

163163
.. configuration-block::
164164

@@ -167,29 +167,29 @@ Now we make the user provider available as a service.
167167
# src/Acme/WebserviceUserBundle/Resources/config/services.yml
168168
parameters:
169169
webservice_user_provider.class: Acme\WebserviceUserBundle\Security\User\WebserviceUserProvider
170-
170+
171171
services:
172172
webservice_user_provider:
173173
class: "%webservice_user_provider.class%"
174-
174+
175175
.. code-block:: xml
176176
177177
<!-- src/Acme/WebserviceUserBundle/Resources/config/services.xml -->
178178
<parameters>
179179
<parameter key="webservice_user_provider.class">Acme\WebserviceUserBundle\Security\User\WebserviceUserProvider</parameter>
180180
</parameters>
181-
181+
182182
<services>
183183
<service id="webservice_user_provider" class="%webservice_user_provider.class%"></service>
184184
</services>
185-
185+
186186
.. code-block:: php
187-
187+
188188
// src/Acme/WebserviceUserBundle/Resources/config/services.php
189189
use Symfony\Component\DependencyInjection\Definition;
190-
190+
191191
$container->setParameter('webservice_user_provider.class', 'Acme\WebserviceUserBundle\Security\User\WebserviceUserProvider');
192-
192+
193193
$container->setDefinition('webservice_user_provider', new Definition('%webservice_user_provider.class%');
194194
195195
.. tip::
@@ -207,7 +207,7 @@ Modify ``security.yml``
207207
-----------------------
208208

209209
In ``/app/config/security.yml`` everything comes together. Add the user provider
210-
to the list of providers in the "security" section. Choose a name for the user provider
210+
to the list of providers in the "security" section. Choose a name for the user provider
211211
(e.g. "webservice") and mention the id of the service you just defined.
212212

213213
.. code-block:: yaml
@@ -218,8 +218,8 @@ to the list of providers in the "security" section. Choose a name for the user p
218218
id: webservice_user_provider
219219
220220
Symfony also needs to know how to encode passwords that are supplied by website
221-
users, e.g. by filling in a login form. You can do this by adding a line to the
222-
"encoders" section in ``/app/config/security.yml``.
221+
users, e.g. by filling in a login form. You can do this by adding a line to the
222+
"encoders" section in ``/app/config/security.yml``.
223223

224224
.. code-block:: yaml
225225
@@ -241,21 +241,21 @@ options, the password may be encoded multiple times and encoded to base64.
241241
nothing, then the submitted password is simply encoded using the algorithm
242242
you specify in ``security.yml``. If a salt *is* specified, then the following
243243
value is created and *then* hashed via the algorithm:
244-
244+
245245
``$password.'{'.$salt.'}';``
246246

247247
If your external users have their passwords salted via a different method,
248248
then you'll need to do a bit more work so that Symfony properly encodes
249249
the password. That is beyond the scope of this entry, but would include
250250
sub-classing ``MessageDigestPasswordEncoder`` and overriding the ``mergePasswordAndSalt``
251251
method.
252-
252+
253253
Additionally, the hash, by default, is encoded multiple times and encoded
254254
to base64. For specific details, see `MessageDigestPasswordEncoder`_.
255255
To prevent this, configure it in ``security.yml``:
256-
256+
257257
.. code-block:: yaml
258-
258+
259259
security:
260260
encoders:
261261
Acme\WebserviceUserBundle\Security\User\WebserviceUser:

0 commit comments

Comments
 (0)