Преглед изворни кода

Merge pull request #732 from Taluu/pr-fix-docs

Update documentation
Thomas пре 13 година
родитељ
комит
ceccdbc3b1

+ 6 - 6
Resources/doc/reference/advance.rst

@@ -4,11 +4,11 @@ Advance
 Service Configuration
 ---------------------
 
-When you create a new Admin service you can configure its dependencies, by default services which are injected are:
+When you create a new Admin service you can configure its dependencies, the services which are injected by default are:
 
-========================      =============================================
+=========================     =============================================
 Dependencies                  Service Id
-========================      =============================================
+=========================     =============================================
 model_manager                 sonata.admin.manager.%manager-type%
 form_contractor               sonata.admin.builder.%manager-type%_form
 show_builder                  sonata.admin.builder.%manager-type%_show
@@ -24,11 +24,11 @@ router_builder                sonata.admin.route.path_info
 label_translator_strategy     sonata.admin.label.strategy.form_component
 =========================     =============================================
 
-Note: %manager-type% is replaced by the manager type (orm, odm...)
+Note: %manager-type% is to be replaced by the manager type (orm, odm...)
 
 You have 2 ways of defining the dependencies inside a ``services.xml``.
 
-* With a tag attribute, less verbose::
+* With a tag attribute, less verbose :
 
 .. code-block:: xml
 
@@ -71,7 +71,7 @@ You have 2 ways of defining the dependencies inside a ``services.xml``.
         </service>
 
 
-If you want to modify the service which is going to be injected, add the following code to your
+If you want to modify the service that is going to be injected, add the following code to your
 application's config file:
 
 .. code-block:: yaml

+ 5 - 5
Resources/doc/reference/architecture.rst

@@ -105,9 +105,9 @@ Inside the controller, the ``Admin`` object is accessible through the
 Obtaining an ``Admin`` Service
 ------------------------------
 
-``Admin`` definitions are accessible through the 'sonata.admin.pool' service or
-directly from the DIC (dependency injection container). The ``Admin`` definitions are lazy
-loaded from the DIC to reduce overhead.
+``Admin`` definitions are accessible through the ``sonata.admin.pool`` service or
+directly from the DIC (dependency injection container). The ``Admin`` definitions 
+are lazy-loaded from the DIC to reduce overhead.
 
 Declaring a new Admin class
 ---------------------------
@@ -116,7 +116,7 @@ Once you have created an admin class, you need to make the framework aware of
 it. To do that, you need to add a tag with the name ``sonata.admin`` to the
 service. Parameters for that tag are:
 
-* ``manager_type``: Label of the document manager to inject;
+* ``manager_type``: Label of the database manager to use;
 * ``group``: A label to allow grouping on the dashboard;
 * ``label``: Label to use for the name of the entity this manager handles;
 
@@ -132,7 +132,7 @@ Examples:
         <argument />
         <argument>Sonata\NewsBundle\Entity\Post</argument>
         <argument>SonataAdminBundle:CRUD</argument>
-</service>
+    </service>
 
 If you want to define your own controller for handling CRUD operations, change the last argument
 in the service definition to::

+ 1 - 1
Resources/doc/reference/batch_actions.rst

@@ -39,7 +39,7 @@ Override the ``getBatchActions`` from your ``Admin`` class to define custom batc
 
 Obviously, a merge action requires two kind of selection : a set of source model to merge into one target model. By default, this bundle only enable the user to select some model, but there is only one selection kind. Thus you will need to override the ``list__batch.html.twig`` template to display both a checkbox (source selection) and a radio (target selection) for each model row. See Symfony bundle overriding mechanism for further explanation.
 
-.. code-block::
+.. code-block:: html+jinja
 
     {# in Acme/ProjectBundle/Resources/views/CRUD/list__batch.html.twig #}
 

+ 1 - 1
Resources/doc/reference/conditional_validation.rst

@@ -64,7 +64,7 @@ There are two important options:
 
 The method must accept two arguments:
 
- - ``ErrorElement``: the instance where assertion can be check
+ - ``ErrorElement``: the instance where assertion can be checked
  - ``value``: the object instance
 
 

+ 1 - 1
Resources/doc/reference/configuration.rst

@@ -10,7 +10,7 @@ Configuration options
 * ``title`` : The admin's title, can be the client name for instance (default: Sonata Admin)
 * ``title_logo`` : logo to use, must be an image with a height of 28px (default : /bundles/sonataadmin/logo_title.png)
 
-Please see :ref:`templates` for more information on how to configure default templates.
+Please see :doc:`templates` for more information on how to configure default templates.
 
 
 Full Configuration Options

+ 5 - 5
Resources/doc/reference/console.rst

@@ -3,17 +3,17 @@ Console/Command-Line Commands
 
 SonataAdminBundle provides the following console commands:
 
-* cache:create-cache-class
-* sonata:admin:explain
-* sonata:admin:list
-* sonata:admin:setup-acl
+* ``cache:create-cache-class``
+* ``sonata:admin:explain``
+* ``sonata:admin:list``
+* ``sonata:admin:setup-acl``
 
 
 cache:create-cache-class
 ------------------------
 
 The ``cache:create-cache-class`` command generates the cache class
-(app/cache/...env.../classes.php) from the classes.map file.
+(``app/cache/...env.../classes.php``) from the classes.map file.
 
 Usage example:
 

+ 4 - 4
Resources/doc/reference/form_help_message.rst

@@ -1,13 +1,13 @@
 Form Help Messages
-==========
+==================
 
 Help Messages
-------------------------
+-------------
 
 Help messages are short notes that are rendered together with form fields. They are generally used to show additional information so the user can complete the form element faster and more accurately.
 
 Example
-----------------
+-------
 
 .. code-block:: php
 
@@ -25,7 +25,7 @@ Example
     }
 
 Alternative Way To Define Help Messages
-----------------
+---------------------------------------
 
 .. code-block:: php
 

+ 29 - 13
Resources/doc/reference/form_types.rst

@@ -9,17 +9,22 @@ The bundle come with different form types to handle model values:
 sonata_type_model
 ^^^^^^^^^^^^^^^^^
 
-The ``Model Type`` allows you to choose an existing model or create new ones. This type doesn't allow to directly edit the selected model.
+The ``Model Type`` allows you to choose an existing model or create new ones. 
+This type doesn't allow to directly edit the selected model.
 
 sonata_type_admin
 ^^^^^^^^^^^^^^^^^
 
-The ``Admin Type`` will delegate the form construction for this model to its related admin class. This type is useful to cascade edition or creation of linked models.
+The ``Admin Type`` will delegate the form construction for this model to its 
+related admin class. This type is useful to cascade edition or creation of 
+linked models.
 
 sonata_type_collection
 ^^^^^^^^^^^^^^^^^^^^^^
 
-The ``Collection Type`` is meant to handle creation and edition of model collections. Rows can be added and deleted, and your model abstraction layer may allow you to edit fields inline.
+The ``Collection Type`` is meant to handle creation and edition of model 
+collections. Rows can be added and deleted, and your model abstraction layer may
+allow you to edit fields inline.
 
 **TIP**: A jQuery event is fired after a row has been added(*sonata-collection-item-added*) or deleted(*sonata-collection-item-deleted*). You can bind to them to trigger some custom javascript imported into your templates(eg: add a calendar widget to a just added date field)
 
@@ -32,27 +37,36 @@ todo
 Field configuration
 ^^^^^^^^^^^^^^^^^^^
 
-- ``admin_code``: Force for any field involving a model the admin class used to handle it (useful for inline editing with ``sonata_type_admin``). The expected value here is the admin service name, not the class name. If not defined, the default admin class for the model type will be used (even if you didn't define any admin for the model type).
+- ``admin_code``: Force for any field involving a model the admin class used to 
+    handle it (useful for inline editing with ``sonata_type_admin``). The 
+    expected value here is the admin service name, not the class name. If not 
+    defined, the default admin class for the model type will be used (even if 
+    you didn't define any admin for the model type).
 
-Other specific field configuration options are detailed in the related abstraction layer documentation.
+Other specific field configuration options are detailed in the related 
+abstraction layer documentation.
 
 Other form types
 ----------------
 
-The bundle comes with some handy form types which are available from outside the scope of the ``SonataAdminBundle``::
+The bundle comes with some handy form types which are available from outside the
+scope of the ``SonataAdminBundle``:
 
 sonata_type_immutable_array
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-The ``Immutable Array`` allows you to edit an array property by defining a type per key.
+The ``Immutable Array`` allows you to edit an array property by defining a type 
+per key.
+
+The type has a ``keys`` parameter which contains the definition for each key. 
+A definition is an array with 3 options :
 
-The type has a ``keys`` parameter which contains the definition for each key. A definition is an array with 3 options :
 * key name
 * type : a type name or a ``FormType`` instance
 * related type parameters : please refer to the related form documentation.
 
-Let's say a ``Page`` have options property with some fixed key-pair values, each value has a different type : integer,
-url, or string for instance.
+Let's say a ``Page`` have options property with some fixed key-pair values, each
+value has a different type : integer, url, or string for instance.
 
 .. code-block:: php
 
@@ -91,16 +105,18 @@ Now, the property can be edited by setting a type for each type
 sonata_type_boolean
 ^^^^^^^^^^^^^^^^^^^
 
-The ``boolean`` type is a specialized ``ChoiceType`` where the choices list is locked to 'yes' and 'no'.
+The ``boolean`` type is a specialized ``ChoiceType`` where the choices list is 
+locked to 'yes' and 'no'.
 
 
 sonata_type_translatable_choice
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-The translatable type is a specialized ``ChoiceType`` where the choices values are translated with the Symfony
-Translator component.
+The translatable type is a specialized ``ChoiceType`` where the choices values 
+are translated with the Symfony Translator component.
 
 The type has one extra parameter :
+
  * ``catalogue`` : the catalogue name to translate the value
 
 

+ 3 - 4
Resources/doc/reference/getting_started.rst

@@ -12,7 +12,6 @@ and create your first admin interface for the models of your application:
 * Step 5: Configuration
 * Step 6: Security
 
-
 Step 1: Define SonataAdminBundle routes
 ---------------------------------------
 
@@ -55,7 +54,7 @@ bundle:
 * SonataDoctrinePhpcrAdminBundle
 
 Propel users are warmly welcome to contribute and create a new bundle for Propel
-ORM that will integrate in SonataAdminBundle.
+ORM that will be integrated in SonataAdminBundle.
 
 Install a persistance servise you need and configure it according to their
 related documentation.
@@ -129,7 +128,7 @@ admin service and link it into the framework by setting the sonata.admin tag.
 
    <container xmlns="http://symfony.com/schema/dic/services"
        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">
+       xsi:schemaLocation="http://symfony.com/schema/dic/services/services-1.0.xsd">
        <services>
           <service id="sonata.admin.course" class="YourNS\AdminBundle\Admin\BlogAdmin">
              <tag name="sonata.admin" manager_type="orm" group="Posts" label="Blog"/>
@@ -216,7 +215,7 @@ Step 6: Security
 The last important step is security. By default, the SonataAdminBundle does not
 come with any user management for ultimate flexibility, however it is most
 likely your application requires such feature. The Sonata Project includes a
-``SonataUserBundle`` which integrates very popular ``FOSUserBundle``. Please
+``SonataUserBundle`` which integrates the very popular ``FOSUserBundle``. Please
 refer to the security section of this documentation for more information.
 
 

+ 18 - 4
Resources/doc/reference/installation.rst

@@ -57,7 +57,22 @@ in your ``deps`` file:
       git=http://github.com/sonata-project/exporter.git
       target=/exporter
 
-and run the vendors script to download bundles::
+You will also need to alter your ``app/config/config.yml`` file :
+
+.. code-block:: yaml
+
+    # app/config/config.yml
+    sonata_block:
+        default_contexts: [cms]
+        blocks:
+            sonata.admin.block.admin_list:
+                contexts:   [admin]
+
+            sonata.block.service.text:
+            sonata.block.service.action:
+            sonata.block.service.rss:
+
+and finally run the vendors script to download bundles::
 
   php bin/vendors install
 
@@ -95,11 +110,10 @@ Now, install the assets from the bundles::
 
     php app/console assets:install web
 
-Usually when installing new bundles a good practice is also to delete your cache::
+Usually when installing new bundles a good practice is to also delete your cache::
 
     php app/console cache:clear
 
 After you have successfully installed above bundles you need to configure
 SonataAdminBundle for administering your models. All that is needed to quickly
-set up SonataAdminBundle is described in the next chapter the Getting started
-with SonataAdminBundle.
+set up SonataAdminBundle is described in the next chapter : :doc:`getting_started`.

+ 4 - 3
Resources/doc/reference/routing.rst

@@ -35,7 +35,7 @@ Routing usage
 
 Inside a CRUD template, a route can be generated by using the ``Admin`` class.
 
-.. code-block:: html
+.. code-block:: html+jinja
 
     <a href="{{ admin.generateUrl('list') }}">List</a>
 
@@ -69,8 +69,9 @@ defined by its name.
 Persistent parameters
 ---------------------
 
-In some cases, the interface might be required to pass the same parameters across the different ``Admin``'s actions.
-Instead of setting them in the template or doing other weird hacks, you can define a ``getPersistentParameters``
+In some cases, the interface might be required to pass the same parameters 
+across the different ``Admin``'s actions. Instead of setting them in the 
+template or doing other weird hacks, you can define a ``getPersistentParameters``
 method. This method will be used when a link is being generated.
 
 .. code-block:: php

+ 8 - 6
Resources/doc/reference/saving_hooks.rst

@@ -1,8 +1,8 @@
 Saving hooks
 ============
 
-When the model is persited upon on the stated object two Admin methods are always called. You can extend this
-method to add custom business logic.
+When the model is persited upon on the stated object two Admin methods are 
+always called. You can extend this method to add custom business logic.
 
     - new object : ``prePersist($object)`` / ``postPersist($object)``
     - edited object : ``preUpdate($object)`` / ``postUpdate($object)``
@@ -12,11 +12,13 @@ method to add custom business logic.
 Example used with the FOS/UserBundle
 ------------------------------------
 
-The ``FOSUserBundle`` provides authentication features for your Symfony2 Project. Compatible with Doctrine ORM & ODM.
-See https://github.com/FriendsOfSymfony/UserBundle for more information.
+The ``FOSUserBundle`` provides authentication features for your Symfony2 Project,
+and is compatible with Doctrine ORM & ODM. See 
+https://github.com/FriendsOfSymfony/UserBundle for more information.
 
-The user management system requires to perform specific call when the user password or username are updated. This
-is how the Admin bundle can be used to solve the issue by using the ``prePersist`` saving hook.
+The user management system requires to perform specific call when the user 
+password or username are updated. This is how the Admin bundle can be used to 
+solve the issue by using the ``prePersist`` saving hook.
 
 .. code-block:: php
 

+ 246 - 190
Resources/doc/reference/security.rst

@@ -4,47 +4,57 @@ Security
 Users management
 ----------------
 
-By default, the SonataAdminBundle does not come with any user management, however it is most likely the application
-requires such feature. The Sonata Project includes a ``SonataUserBundle`` which integrates the ``FOSUserBundle``.
+By default, the SonataAdminBundle does not come with any user management, 
+however it is most likely the application requires such feature. The Sonata 
+Project includes a ``SonataUserBundle`` which integrates the ``FOSUserBundle``.
 
-The ``FOSUserBundle`` adds support for a database-backed user system in Symfony2. It provides a flexible framework
-for user management that aims to handle common tasks such as user login, registration and password retrieval.
+The ``FOSUserBundle`` adds support for a database-backed user system in Symfony2.
+It provides a flexible framework for user management that aims to handle common 
+tasks such as user login, registration and password retrieval.
 
-The ``SonataUserBundle`` is just a thin wrapper to include the ``FOSUserBundle`` into the ``AdminBundle``. The
-``SonataUserBundle`` includes :
+The ``SonataUserBundle`` is just a thin wrapper to include the ``FOSUserBundle``
+into the ``AdminBundle``. The ``SonataUserBundle`` includes :
 
 * A default login area
-* A default ``user_block`` template which is used to display the current user and the logout link
+* A default ``user_block`` template which is used to display the current user 
+  and the logout link
 * 2 Admin classes : User and Group
 * A default class for User and Group.
 
-There is a little magic in the ``SonataAdminBundle`` if the bundle detects the ``SonataUserBundle`` class, then
-the default ``user_block`` template will be changed to use the one provided by the ``SonataUserBundle``.
+There is a little magic in the ``SonataAdminBundle`` : if the bundle detects the 
+``SonataUserBundle`` class, then the default ``user_block`` template will be 
+changed to use the one provided by the ``SonataUserBundle``.
 
-The install process is available on the dedicated `SonataUserBundle's documentation area <http://sonata-project.org/bundles/user/master/doc/reference/installation.html>`_
+The install process is available on the dedicated `SonataUserBundle's 
+documentation area 
+<http://sonata-project.org/bundles/user/master/doc/reference/installation.html>`_
 
 
 Security handlers
 -----------------
 
-The security part is managed by a ``SecurityHandler``, the bundle comes with 3 handlers
+The security part is managed by a ``SecurityHandler``, the bundle comes with 3 
+handlers
 
   - ``sonata.admin.security.handler.role`` : ROLES to handle permissions
   - ``sonata.admin.security.handler.acl`` : ACL and ROLES to handle permissions
-  - ``sonata.admin.security.handler.noop`` : always returns true, can be used with the Symfony2 firewall
+  - ``sonata.admin.security.handler.noop`` : always returns true, can be used 
+    with the Symfony2 firewall
 
-The default value is ``sonata.admin.security.handler.noop``, if you want to change the default value
-you can set the ``security_handler`` to ``sonata.admin.security.handler.acl`` or ``sonata.admin.security.handler.role``.
+The default value is ``sonata.admin.security.handler.noop``, if you want to 
+change the default value you can set the ``security_handler`` to 
+``sonata.admin.security.handler.acl`` or ``sonata.admin.security.handler.role``.
 
-To quickly secure an admin the role security can be used. It allows to specify the actions a user can with the admin. The ACL
-security system is more advanced and allows to secure the objects. For people using the previous ACL implementation,
-you can switch the security_handler to the role security handler.
+To quickly secure an admin the role security can be used. It allows to specify 
+the actions a user can with the admin. The ACL security system is more advanced 
+and allows to secure the objects. For people using the previous ACL 
+implementation, you can switch the security_handler to the role security handler.
 
 Configuration
 ~~~~~~~~~~~~~
 
-Only the security handler is required to determine which type of security to use. The other parameters are set as default,
-change them if needed.
+Only the security handler is required to determine which type of security to use. 
+The other parameters are set as default, change them if needed.
 
 Using roles:
 
@@ -83,27 +93,30 @@ Using ACL:
             # permission related to the objects
             object_permissions: [VIEW, EDIT, DELETE, UNDELETE, OPERATOR, MASTER, OWNER]
 
-The following section explains how to set up ACL with the ``FriendsOfSymfony/UserBundle``.
+The following section explains how to set up ACL with the 
+``FriendsOfSymfony/UserBundle``.
 
 ACL and FriendsOfSymfony/UserBundle
 -----------------------------------
 
 If you want an easy way to handle users, please use :
 
- - https://github.com/FriendsOfSymfony/FOSUserBundle : handle users and groups stored in RDMS or MongoDB
- - https://github.com/sonata-project/SonataUserBundle : integrates the ``FriendsOfSymfony/UserBundle`` with
-   the ``AdminBundle``
+ - https://github.com/FriendsOfSymfony/FOSUserBundle : handle users and groups 
+    stored in RDMS or MongoDB
+ - https://github.com/sonata-project/SonataUserBundle : integrates the 
+    ``FriendsOfSymfony/UserBundle`` with the ``AdminBundle``
 
 The security integration is a work in progress and has some known issues :
  - ACL permissions are immutables
- - A listener must be implemented that creates the object Access Control List with the required rules if objects are
-   created outside the Admin
+ - A listener must be implemented that creates the object Access Control List 
+    with the required rules if objects are created outside the Admin
 
 Configuration
 ~~~~~~~~~~~~~
 
-Before you can use ``FriendsOfSymfony/FOSUserBundle`` you need to set it up as described in the documentation
-of the bundle. In step 4 you need to create a User class (in a custom UserBundle). Do it as follows:
+Before you can use ``FriendsOfSymfony/FOSUserBundle`` you need to set it up as 
+described in the documentation of the bundle. In step 4 you need to create a 
+User class (in a custom UserBundle). Do it as follows:
 
 .. code-block:: php
 
@@ -147,7 +160,8 @@ The following configuration for the SonataUserBundle defines:
 
     - the ``FriendsOfSymfony/FOSUserBundle`` as a security provider
     - the login form for authentification
-    - the access control : resources with related required roles, the important part is the admin configuration
+    - the access control : resources with related required roles, the important 
+        part is the admin configuration
     - the ``acl`` option to enable the ACL.
     - the ``AdminPermissionMap`` defines the permissions of the Admin class
 
@@ -224,219 +238,261 @@ In ``app/config/security.yml``:
 .. code-block:: sh
 
     # php app/console fos:user:create --super-admin
-    Please choose a username:root
-    Please choose an email:root@domain.com
-    Please choose a password:root
-    Created user root
+        Please choose a username:root
+        Please choose an email:root@domain.com
+        Please choose a password:root
+        Created user root
 
 If you have Admin classes, you can install or update the related CRUD ACL rules :
 
 .. code-block:: sh
 
     # php app/console sonata:admin:setup-acl
-    Starting ACL AdminBundle configuration
-    > install ACL for sonata.media.admin.media
-       - add role: ROLE_SONATA_MEDIA_ADMIN_MEDIA_GUEST, permissions: ["VIEW","LIST"]
-       - add role: ROLE_SONATA_MEDIA_ADMIN_MEDIA_STAFF, permissions: ["EDIT","LIST","CREATE"]
-       - add role: ROLE_SONATA_MEDIA_ADMIN_MEDIA_EDITOR, permissions: ["OPERATOR"]
-       - add role: ROLE_SONATA_MEDIA_ADMIN_MEDIA_ADMIN, permissions: ["MASTER"]
-    ... skipped ...
+        Starting ACL AdminBundle configuration
+        > install ACL for sonata.media.admin.media
+        - add role: ROLE_SONATA_MEDIA_ADMIN_MEDIA_GUEST, permissions: ["VIEW","LIST"]
+        - add role: ROLE_SONATA_MEDIA_ADMIN_MEDIA_STAFF, permissions: ["EDIT","LIST","CREATE"]
+        - add role: ROLE_SONATA_MEDIA_ADMIN_MEDIA_EDITOR, permissions: ["OPERATOR"]
+        - add role: ROLE_SONATA_MEDIA_ADMIN_MEDIA_ADMIN, permissions: ["MASTER"]
+        ... skipped ...
 
 
-If you already have objects, you can generate the object ACL rules for each object of an admin:
+If you already have objects, you can generate the object ACL rules for each 
+object of an admin:
 
 .. code-block:: sh
 
     $ php app/console sonata:admin:generate-object-acl
 
-Optionally, you can specify an object owner, and step through each admin. See the help of the command for more information.
+Optionally, you can specify an object owner, and step through each admin. See 
+the help of the command for more information.
 
-If you try to access to the admin class you should see the login form, just logon with the ``root`` user.
+If you try to access to the admin class you should see the login form, just 
+log in with the ``root`` user.
 
-An Admin is displayed in the dashboard (and menu) when the user has the role ``LIST``. To change this override the ``showIn``
-method in the Admin class.
+An Admin is displayed in the dashboard (and menu) when the user has the role 
+``LIST``. To change this override the ``showIn`` method in the Admin class.
 
 Roles and Access control lists
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-A user can have several roles when working with an application. Each Admin class has several roles, and each role specifies the permissions
-of the user for the Admin class. Or more specific, what the user can do with the domain object(s) the Admin class is created for.
-
-By default each Admin class contains the following roles, override the property ``$securityInformation`` to change this:
-
- - ROLE_SONATA_..._GUEST: a guest that is allowed to view an object and a list of objects;
- - ROLE_SONATA_..._STAFF: probably the biggest part of the users, a staff user has the same permissions as guests and is additionally
-   allowed to EDIT and CREATE new objects;
- - ROLE_SONATA_..._EDITOR: an editor is granted all access and, compared to the staff users, is allowed to DELETE;
- - ROLE_SONATA_..._ADMIN: an administrative user is granted all access and on top of that, the user is allowed to grant other users access.
+A user can have several roles when working with an application. Each Admin class 
+has several roles, and each role specifies the permissions of the user for the 
+``Admin`` class. Or more specifically, what the user can do with the domain object(s) 
+the ``Admin`` class is created for.
+
+By default each ``Admin`` class contains the following roles, override the 
+property ``$securityInformation`` to change this:
+
+ - ``ROLE_SONATA_..._GUEST`` : a guest that is allowed to view an object and a 
+    list of objects;
+ - ``ROLE_SONATA_..._STAFF`` : probably the biggest part of the users, a staff 
+    user  has the same permissions as guests and is additionally allowed to 
+    ``EDIT`` and ``CREATE`` new objects;
+ - ``ROLE_SONATA_..._EDITOR`` : an editor is granted all access and, compared to
+    the staff users, is allowed to ``DELETE``;
+ - ``ROLE_SONATA_..._ADMIN`` : an administrative user is granted all access and 
+    on top of that, the user is allowed to grant other users access.
 
 Owner:
- - when an object is created, the currently logged in user is set as owner for that object and is granted all access for that object;
- - this means the user owning the object is always allowed to DELETE the object, even when it only has the staff role.
+ - when an object is created, the currently logged in user is set as owner for 
+    that object and is granted all access for that object;
+ - this means the user owning the object is always allowed to ``DELETE`` the 
+    object, even when it only has the staff role.
 
 Vocabulary used for Access Control Lists:
- - Role: a user role;
-  - ACL: a list of access rules, the Admin uses 2 types:
-   - Admin ACL: created from the Security information of the Admin class for each admin and shares the Access Control Entries that specify
-     what the user can do (permissions) with the admin
-   - Object ACL: also created from the security information of the Admin class however created for each object, it uses 2 scopes:
-    - Class-Scope: the class scope contains the rules that are valid for all object of a certain class;
-    - Object-Scope: specifies the owner;
-  - Sid: Security identity, an ACL role for the Class-Scope ACL and the user for the Object-Scope ACL;
-  - Oid: Object identity, identifies the ACL, for the admin ACL this is the admin code, for the object ACL this is the object id;
-  - ACE: a role (or sid) and its permissions;
-  - Permission: this tells what the user is allowed to do with the Object identity;
-  - Bitmask: a permission can have several bitmasks, each bitmask represents a permission. When permission VIEW is requested and
-    it contains the VIEW and EDIT bitmask and the user only has the EDIT permission, then the permission VIEW is granted.
-  - PermissionMap: configures the bitmasks for each permission, to change the default mapping create a voter for the domain class of the Admin.
-    There can be many voters that may have different permission maps. However, prevent that multiple voters vote on the same class with
-    overlapping bitmasks.
-
-See the cookbook article "Advanced ACL concepts" for the meaning of the different permissions:
+ - **Role :** a user role;
+    - **ACL :** a list of access rules, the Admin uses 2 types:
+    - **Admin ACL :** created from the Security information of the Admin class 
+        for  each admin and shares the Access Control Entries that specify what
+        the  user can do (permissions) with the admin
+    - **Object ACL :** also created from the security information of the ``Admin``
+        class however created for each object, it uses 2 scopes:
+
+        - **Class-Scope :** the class scope contains the rules that are valid 
+            for all object of a certain class;
+        - **Object-Scope :** specifies the owner;
+    - **Sid :** Security identity, an ACL role for the Class-Scope ACL and the 
+        user for the Object-Scope ACL;
+    - **Oid :** Object identity, identifies the ACL, for the admin ACL this is 
+        the admin code, for the object ACL this is the object id;
+    - **ACE :** a role (or sid) and its permissions;
+    - **Permission :** this tells what the user is allowed to do with the Object
+        identity;
+    - **Bitmask :** a permission can have several bitmasks, each bitmask 
+        represents a permission. When permission ``VIEW`` is requested and it 
+        contains the ``VIEW`` and ``EDIT`` bitmask and the user only has the 
+        ``EDIT`` permission, then the permission ``VIEW`` is granted.
+    - **PermissionMap :** configures the bitmasks for each permission, to change
+        the default mapping create a voter for the domain class of the Admin.
+    
+    There can be many voters that may have different permission maps. However, 
+    prevent that multiple voters vote on the same class with overlapping bitmasks.
+
+See the cookbook article "Advanced ACL concepts" for the meaning of the different
+permissions:
 http://symfony.com/doc/current/cookbook/security/acl_advanced.html#pre-authorization-decisions.
 
 How is access granted?
 ~~~~~~~~~~~~~~~~~~~~~~
-In the application the security context is asked if access is granted for a role or a permission (admin.isGranted):
 
- - Token: a token identifies a user between requests;
- - Voter: sort of judge that returns if access is granted of denied, if the voter should not vote for a case, it returns abstrain;
- - AccessDecisionManager: decides if access is granted or denied according a specific strategy. It grants access if at least one (affirmative
-   strategy), all (unanimous strategy) or more then half (consensus strategy) of the counted votes granted access;
- - RoleVoter: votes for all attributes stating with "ROLE_" and grants access if the user has this role;
- - RoleHierarchieVoter: when the role ROLE_SONATA_ADMIN is voted for, it also votes "granted" if the user has the role ROLE_SUPER_ADMIN;
- - AclVoter: grants access for the permissions of the Admin class if the user has the permission, the user has a permission that is
-   included in the bitmasks of the permission requested to vote for or the user owns the object.
+In the application the security context is asked if access is granted for a role
+or a permission (``admin.isGranted``):
+
+ - **Token :** a token identifies a user between requests;
+ - **Voter :** sort of judge that returns if access is granted of denied, if the
+    voter should not vote for a case, it returns abstrain;
+ - **AccessDecisionManager :** decides if access is granted or denied according 
+    a specific strategy. It grants access if at least one (affirmative strategy),
+    all (unanimous strategy) or more then half (consensus strategy) of the 
+    counted votes granted access;
+ - **RoleVoter :** votes for all attributes stating with ``ROLE_`` and grants 
+    access if the user has this role;
+ - **RoleHierarchieVoter :** when the role ``ROLE_SONATA_ADMIN`` is voted for, 
+    it also votes "granted" if the user has the role ``ROLE_SUPER_ADMIN``;
+ - **AclVoter :** grants access for the permissions of the ``Admin`` class if 
+    the user has the permission, the user has a permission that is included in 
+    the bitmasks of the permission requested to vote for or the user owns the 
+    object.
 
 Create a custom voter or a custom permission map
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-In some occasions you need to create a custom voter or a custom permission map because for example you want to restrict access using extra rules:
+In some occasions you need to create a custom voter or a custom permission map 
+because for example you want to restrict access using extra rules:
 
- - create a custom voter class that extends the AclVoter
+- create a custom voter class that extends the ``AclVoter``
 
-.. code-block:: php
+    .. code-block:: php
 
-   namespace Acme\DemoBundle\Security\Authorization\Voter;
-
-   use FOS\UserBundle\Model\UserInterface;
-   use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
-   use Symfony\Component\Security\Acl\Voter\AclVoter;
-
-   class UserAclVoter extends AclVoter
-   {
-       /**
-        * {@InheritDoc}
-        */
-       public function supportsClass($class)
-       {
-           // support the Class-Scope ACL for votes with the custom permission map
-           // return $class === 'Sonata\UserBundle\Admin\Entity\UserAdmin' || $is_subclass_of($class, 'FOS\UserBundle\Model\UserInterface');
-           // if you use php >=5.3.7 you can check the inheritance with is_a($class, 'Sonata\UserBundle\Admin\Entity\UserAdmin');
-           // support the Object-Scope ACL
-           return is_subclass_of($class, 'FOS\UserBundle\Model\UserInterface');
-       }
-
-       public function supportsAttribute($attribute)
-       {
-           return $attribute === 'EDIT' || $attribute === 'DELETE';
-       }
-
-       public function vote(TokenInterface $token, $object, array $attributes)
-       {
-           if (!$this->supportsClass(get_class($object))) {
-               return self::ACCESS_ABSTAIN;
-           }
-
-           foreach ($attributes as $attribute) {
-               if ($this->supportsAttribute($attribute) && $object instanceof UserInterface) {
-                   if ($object->isSuperAdmin() && !$token->getUser()->isSuperAdmin()) {
-                       // deny a non super admin user to edit a super admin user
-                       return self::ACCESS_DENIED;
-                   }
-               }
-           }
-
-           // use the parent vote with the custom permission map:
-           // return parent::vote($token, $object, $attributes);
-           // otherwise leave the permission voting to the AclVoter that is using the default permission map
-           return self::ACCESS_ABSTAIN;
-       }
-   }
-
- - optionally create a custom permission map, copy to start the Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap.php to your bundle
-
- - declare the voter and permission map as a service
-
-.. code-block:: xml
-
-    <!-- src/Acme/DemoBundle/Resources/config/services.xml -->
-
-    <parameters>
-        <parameter key="security.acl.user_voter.class">Acme\DemoBundle\Security\Authorization\Voter\UserAclVoter</parameter>
-        <!-- <parameter key="security.acl.user_permission.map.class">Acme\DemoBundle\Security\Acl\Permission\UserAdminPermissionMap</parameter> -->
-    </parameters>
-
-    <services>
-        <!-- <service id="security.acl.user_permission.map" class="%security.acl.permission.map.class%" public="false"></service> -->
-
-        <service id="security.acl.voter.user_permissions" class="%security.acl.user_voter.class%" public="false">
-            <tag name="monolog.logger" channel="security" />
-            <argument type="service" id="security.acl.provider" />
-            <argument type="service" id="security.acl.object_identity_retrieval_strategy" />
-            <argument type="service" id="security.acl.security_identity_retrieval_strategy" />
-            <argument type="service" id="security.acl.permission.map" />
-            <argument type="service" id="logger" on-invalid="null" />
-            <tag name="security.voter" priority="255" />
-        </service>
-    </services>
-
- - change the access decission strategy to ``unanimous``
+        <?php
 
-.. code-block:: yaml
+        namespace Acme\DemoBundle\Security\Authorization\Voter;
 
-    # app/config/security.yml
-    security:
-        access_decision_manager:
-            # Strategy can be: affirmative, unanimous or consensus
-            strategy: unanimous
+        use FOS\UserBundle\Model\UserInterface;
+        use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+        use Symfony\Component\Security\Acl\Voter\AclVoter;
+
+        class UserAclVoter extends AclVoter
+        {
+            /**
+            * {@InheritDoc}
+            */
+            public function supportsClass($class)
+            {
+                // support the Class-Scope ACL for votes with the custom permission map
+                // return $class === 'Sonata\UserBundle\Admin\Entity\UserAdmin' || $is_subclass_of($class, 'FOS\UserBundle\Model\UserInterface');
+                // if you use php >=5.3.7 you can check the inheritance with is_a($class, 'Sonata\UserBundle\Admin\Entity\UserAdmin');
+                // support the Object-Scope ACL
+                return is_subclass_of($class, 'FOS\UserBundle\Model\UserInterface');
+            }
+
+            public function supportsAttribute($attribute)
+            {
+                return $attribute === 'EDIT' || $attribute === 'DELETE';
+            }
+
+            public function vote(TokenInterface $token, $object, array $attributes)
+            {
+                if (!$this->supportsClass(get_class($object))) {
+                    return self::ACCESS_ABSTAIN;
+                }
+
+                foreach ($attributes as $attribute) {
+                    if ($this->supportsAttribute($attribute) && $object instanceof UserInterface) {
+                        if ($object->isSuperAdmin() && !$token->getUser()->isSuperAdmin()) {
+                            // deny a non super admin user to edit a super admin user
+                            return self::ACCESS_DENIED;
+                        }
+                    }
+                }
+
+                // use the parent vote with the custom permission map:
+                // return parent::vote($token, $object, $attributes);
+                // otherwise leave the permission voting to the AclVoter that is using the default permission map
+                return self::ACCESS_ABSTAIN;
+            }
+        }
+
+- optionally create a custom permission map, copy to start the 
+    ``Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap.php`` to 
+    your bundle
+
+- declare the voter and permission map as a service
+
+    .. code-block:: xml
+
+        <!-- src/Acme/DemoBundle/Resources/config/services.xml -->
+
+        <parameters>
+            <parameter key="security.acl.user_voter.class">Acme\DemoBundle\Security\Authorization\Voter\UserAclVoter</parameter>
+            <!-- <parameter key="security.acl.user_permission.map.class">Acme\DemoBundle\Security\Acl\Permission\UserAdminPermissionMap</parameter> -->
+        </parameters>
+
+        <services>
+            <!-- <service id="security.acl.user_permission.map" class="%security.acl.permission.map.class%" public="false"></service> -->
+
+            <service id="security.acl.voter.user_permissions" class="%security.acl.user_voter.class%" public="false">
+                <tag name="monolog.logger" channel="security" />
+                <argument type="service" id="security.acl.provider" />
+                <argument type="service" id="security.acl.object_identity_retrieval_strategy" />
+                <argument type="service" id="security.acl.security_identity_retrieval_strategy" />
+                <argument type="service" id="security.acl.permission.map" />
+                <argument type="service" id="logger" on-invalid="null" />
+                <tag name="security.voter" priority="255" />
+            </service>
+        </services>
+
+- change the access decission strategy to ``unanimous``
+
+    .. code-block:: yaml
+
+        # app/config/security.yml
+        security:
+            access_decision_manager:
+                # Strategy can be: affirmative, unanimous or consensus
+                strategy: unanimous
 
- - to make this work the permission needs to be checked using the Object ACL
+- to make this work the permission needs to be checked using the Object ACL
 
-  - modify the template (or code) where applicable:
+    - modify the template (or code) where applicable:
 
-.. code-block:: html
+        .. code-block:: html+jinja
 
-    {% if admin.isGranted('EDIT', user_object) %} {# ... #} {% endif %}
+            {% if admin.isGranted('EDIT', user_object) %} {# ... #} {% endif %}
 
-  - because the object ACL permission is checked, the ACL for the object must have been created, otherwise the AclVoter
-    will deny EDIT access for a non super admin user trying to edit another non super admin user. This is automatically done when the object is
-    created using the Admin. If objects are also created outside the Admin, have a look at the ``createSecurityObject`` method in the
-    AclSecurityHandler.
+    - because the object ACL permission is checked, the ACL for the object must 
+        have been created, otherwise the ``AclVoter`` will deny ``EDIT`` access
+        for a non super admin user trying to edit another non super admin user. 
+        This is automatically done when the object is created using the Admin. 
+        If objects are also created outside the Admin, have a look at the 
+        ``createSecurityObject`` method in the ``AclSecurityHandler``.
 
 Usage
 ~~~~~
 
-Everytime you create a new ``Admin`` class, you should create start the command ``php app/console sonata:admin:setup-acl``
-so the ACL database will be updated with the latest roles and permissions.
+Everytime you create a new ``Admin`` class, you should start with the command 
+``php app/console sonata:admin:setup-acl`` so the ACL database will be updated 
+with the latest roles and permissions.
 
-In the templates, or in your code, you can use the Admin method ``isGranted``:
+In the templates, or in your code, you can use the Admin method ``isGranted()`` :
 
- - check for an admin that the user is allowed to EDIT:
+- check for an admin that the user is allowed to ``EDIT`` :
 
-.. code-block:: html
+    .. code-block:: html+jinja
 
-    {# use the admin security method  #}
-    {% if admin.isGranted('EDIT') %} {# ... #} {% endif %}
+        {# use the admin security method  #}
+        {% if admin.isGranted('EDIT') %} {# ... #} {% endif %}
 
-    {# or use the default is_granted symfony helper, the following will give the same result #}
-    {% if is_granted('ROLE_SUPER_ADMIN') or is_granted('EDIT', admin) %} {# ... #} {% endif %}
+        {# or use the default is_granted symfony helper, the following will give the same result #}
+        {% if is_granted('ROLE_SUPER_ADMIN') or is_granted('EDIT', admin) %} {# ... #} {% endif %}
 
- - check for an admin that the user is allowed to DELETE, the object is added to also check if the object owner is allowed to DELETE:
+- check for an admin that the user is allowed to ``DELETE``, the object is added
+    to also check if the object owner is allowed to ``DELETE`` :
 
-.. code-block:: html
+    .. code-block:: html+jinja
 
-    {# use the admin security method  #}
-    {% if admin.isGranted('DELETE', object) %} {# ... #} {% endif %}
+        {# use the admin security method  #}
+        {% if admin.isGranted('DELETE', object) %} {# ... #} {% endif %}
 
-    {# or use the default is_granted symfony helper, the following will give the same result #}
-    {% if is_granted('ROLE_SUPER_ADMIN') or is_granted('DELETE', object) %} {# ... #} {% endif %}
+        {# or use the default is_granted symfony helper, the following will give the same result #}
+        {% if is_granted('ROLE_SUPER_ADMIN') or is_granted('DELETE', object) %} {# ... #} {% endif %}

+ 58 - 41
Resources/doc/reference/translation.rst

@@ -3,42 +3,45 @@ Translation
 
 There are two main catalogue names in an Admin class:
 
-* ``SonataAdminBundle`` : this catalogue is used to translate shared messages accross different admins
-* ``messages`` : this catalogue is used to translate the messages for the current admin
+* ``SonataAdminBundle`` : this catalogue is used to translate shared messages 
+    accross different admins
+* ``messages`` : this catalogue is used to translate the messages for the current
+    admin
 
-Ideally the ``messages`` catalogue should be changed to avoid any issues with other Admin classes.
+Ideally the ``messages`` catalogue should be changed to avoid any issues with 
+other Admin classes.
 
 You have two options to configure the catalogue for the admin class:
 
 * one by defining a property
 
-.. code-block:: php
+    .. code-block:: php
 
-    <?php
-    class PageAdmin extends Admin
-    {
-        protected $translationDomain = 'SonataPageBundle';
-    }
+        <?php
+        class PageAdmin extends Admin
+        {
+            protected $translationDomain = 'SonataPageBundle';
+        }
 
 
 * or by injecting the value through the container
 
-.. code-block:: xml
+    .. code-block:: xml
 
-        <service id="sonata.page.admin.page" class="Sonata\PageBundle\Admin\PageAdmin">
-            <tag name="sonata.admin" manager_type="orm" group="sonata_page" label="page"/>
-            <argument />
-            <argument>Application\Sonata\PageBundle\Entity\Page</argument>
-            <argument />
+            <service id="sonata.page.admin.page" class="Sonata\PageBundle\Admin\PageAdmin">
+                <tag name="sonata.admin" manager_type="orm" group="sonata_page" label="page"/>
+                <argument />
+                <argument>Application\Sonata\PageBundle\Entity\Page</argument>
+                <argument />
 
-            <call method="setTranslationDomain">
-                <argument>SonataPageBundle</argument>
-            </call>
-        </service>
+                <call method="setTranslationDomain">
+                    <argument>SonataPageBundle</argument>
+                </call>
+            </service>
 
 
-An admin instance always gets the ``translator`` instance, so it can be used to translate messages within the
-``configure*Fields`` method or in templates.
+An admin instance always gets the ``translator`` instance, so it can be used to 
+translate messages within the ``configure*Fields`` method or in templates.
 
 .. code-block:: jinja
 
@@ -57,10 +60,12 @@ The later solution is more flexible as no catalogue parameters are hardcoded.
 Translate field labels
 ----------------------
 
-The Admin bundle comes with a customized form field template. The most notable changes from the original one is the use
-of the translation domain provided by the Admin instance to translate label.
+The Admin bundle comes with a customized form field template. The most notable 
+changes from the original one is the use of the translation domain provided by 
+the Admin instance to translate label.
 
-By default, the label is the field name. However a label can be defined as third argument of the ``add`` method:
+By default, the label is the field name. However a label can be defined as 
+third argument of the ``add`` method:
 
 .. code-block:: php
 
@@ -73,28 +78,38 @@ By default, the label is the field name. However a label can be defined as third
         }
     }
 
-There is another option for rapid prototyping or to avoid spending too much time adding the ``label`` key to all option
-fields: ``Label Strategies``. By default labels are generated by using a simple rule ::
+There is another option for rapid prototyping or to avoid spending too much time
+adding the ``label`` key to all option fields: ``Label Strategies``. By default 
+labels are generated by using a simple rule ::
 
     isValid => Is Valid
 
 .. note::
 
-    For early adopter, you can use a specific backward compatible service to keep your current translation.
+    For early adopter, you can use a specific backward compatible service to 
+    keep your current translation.
 
 The ``AdminBundle`` comes with different key label generation strategies:
 
-* ``sonata.admin.label.strategy.native`` : DEFAULT - Makes the string human readable readable - ``isValid`` => ``Is Valid``
-* ``sonata.admin.label.strategy.form_component`` : The default behavior from the Form Component - ``isValid`` => ``Isvalid``)
-* ``sonata.admin.label.strategy.underscore`` : Adds undescore to the label  - ``isValid`` => ``form.label_is_valid``
-* ``sonata.admin.label.strategy.noop`` : does not alter the string - ``isValid`` => ``isValid``
-* ``sonata.admin.label.strategy.bc`` : preserves the old label generation from the early version of ``SonataAdminBundle``
-
-``sonata.admin.label.strategy.underscore`` will be better for i18n applications and ``sonata.admin.label.strategy.native`
-will be better for native language based on the field name. So it is possible to start with the ``native`` strategy and then
-when the application needs to be translated using generic keys the configuration can be switched to the ``sonata.admin.label.strategy.underscore``.
-
-The strategy can be quickly configured when the Admin class is registered into the Container:
+* ``sonata.admin.label.strategy.native`` : DEFAULT - Makes the string human 
+    readable readable - ``isValid`` => ``Is Valid``
+* ``sonata.admin.label.strategy.form_component`` : The default behavior from the
+    Form Component - ``isValid`` => ``Isvalid``)
+* ``sonata.admin.label.strategy.underscore`` : Adds undescore to the label  - 
+    ``isValid`` => ``form.label_is_valid``
+* ``sonata.admin.label.strategy.noop`` : does not alter the string - ``isValid`` 
+    => ``isValid``
+* ``sonata.admin.label.strategy.bc`` : preserves the old label generation from 
+    the early version of ``SonataAdminBundle``
+
+``sonata.admin.label.strategy.underscore`` will be better for i18n applications 
+and ``sonata.admin.label.strategy.native` will be better for native language 
+based on the field name. So it is possible to start with the ``native`` strategy
+and then when the application needs to be translated using generic keys the 
+configuration can be switched to the ``sonata.admin.label.strategy.underscore``.
+
+The strategy can be quickly configured when the Admin class is registered into 
+the Container:
 
 .. code-block:: xml
 
@@ -113,10 +128,12 @@ The strategy can be quickly configured when the Admin class is registered into t
 
 .. note::
 
-    In all cases the label will be used by the ``Translator``. The strategy is just a quick way to generate translatable keys.
-    It all depends on the project's requirements.
+    In all cases the label will be used by the ``Translator``. The strategy is 
+    just a quick way to generate translatable keys. It all depends on the 
+    project's requirements.
 
 
 .. note::
 
-   When the strategy method is called, a context (form, filter, list, show) and a type (link, label, etc ...) arguments are passed.
+    When the strategy method is called, a context (form, filter, list, show) and
+    a type (link, label, etc ...) arguments are passed.