Skip to content

Commit

Permalink
Merge 3.x into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed Mar 26, 2019
2 parents d44519f + fd362bf commit ce5dd00
Show file tree
Hide file tree
Showing 14 changed files with 232 additions and 238 deletions.
2 changes: 1 addition & 1 deletion docs/cookbook/recipe_delete_field_group.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ This is optional. However, when not provided, it will be assumed that
you mean the 'default' tab. If the group is on another tab, it won't be
removed, when this is not provided. There is a third optional argument
for the method, which let's you choose, whether or not, tabs are also
removed, if you happen to remove all groups of a tab. This behaviour
removed, if you happen to remove all groups of a tab. This behavior
is disabled by default, but can be enabled, by setting the third
argument of ``removeGroup`` to ``true``.
5 changes: 2 additions & 3 deletions docs/cookbook/recipe_icheck.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ If you don't want to use iCheck in your admin, you can disable it in configurati
Disable iCheck on some form elements
-------------------------------------

To disable iCheck on some ``checkbox`` or ``radio`` form elements, set data attribute ``data-sonata-icheck = "false"`` to this form element.

.. code-block:: php
To disable iCheck on some ``checkbox`` or ``radio`` form elements,
set data attribute ``data-sonata-icheck = "false"`` to this form element::

use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\ModelType;
Expand Down
27 changes: 14 additions & 13 deletions docs/cookbook/recipe_improve_performance_large_datasets.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Improve performance of large datasets
Improve Performance of Large Datasets
=====================================

If your database table contains thousands of records, the database queries generated
Expand All @@ -17,17 +17,6 @@ To use `SimplePager` in your admin, define ``pager_type`` in the service defini

.. configuration-block::

.. code-block:: xml
<!-- config/services.xml -->
<service id="app.admin.post" class="App\Admin\PostAdmin">
<argument/>
<argument>App\Entity\Post</argument>
<argument/>
<tag name="sonata.admin" manager_type="orm" group="Content" label="Post" pager_type="simple"/>
</service>
.. code-block:: yaml
# config/services.yaml
Expand All @@ -42,6 +31,18 @@ To use `SimplePager` in your admin, define ``pager_type`` in the service defini
tags:
- { name: sonata.admin, manager_type: orm, group: 'Content', label: 'Post', pager_type: 'simple' }
.. code-block:: xml
<!-- config/services.xml -->
<service id="app.admin.post" class="App\Admin\PostAdmin">
<argument/>
<argument>App\Entity\Post</argument>
<argument/>
<tag name="sonata.admin" manager_type="orm" group="Content" label="Post" pager_type="simple"/>
</service>
.. note::

The ``pager_results`` template is automatically changed to ``@SonataAdmin/Pager/simple_pager_results.html.twig`` if it's not already overloaded.
The ``pager_results`` template is automatically changed to
``@SonataAdmin/Pager/simple_pager_results.html.twig`` if it's not already overloaded.
52 changes: 26 additions & 26 deletions docs/cookbook/recipe_persisting_filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,6 @@ Per Admin :

.. configuration-block::

.. code-block:: xml
<!-- config/services.xml -->
<service id="app.admin.user" class="App\Admin\UserAdmin">
<argument/>
<argument>App\Entity\User</argument>
<argument/>
<tag
name="sonata.admin"
manager_type="orm"
filter_persister="filter_persister_service_id"
/>
</service>
.. code-block:: yaml
# config/services.yaml
Expand All @@ -83,6 +68,21 @@ Per Admin :
manager_type: orm
filter_persister: filter_persister_service_id
.. code-block:: xml
<!-- config/services.xml -->
<service id="app.admin.user" class="App\Admin\UserAdmin">
<argument/>
<argument>App\Entity\User</argument>
<argument/>
<tag
name="sonata.admin"
manager_type="orm"
filter_persister="filter_persister_service_id"
/>
</service>
Disable filters persistence for some Admin
------------------------------------------

Expand All @@ -94,17 +94,6 @@ You can disable it per Admin if you want.

.. configuration-block::

.. code-block:: xml
<!-- config/services.xml -->
<service id="app.admin.user" class="App\Admin\UserAdmin">
<argument/>
<argument>App\Entity\User</argument>
<argument/>
<tag name="sonata.admin" manager_type="orm" persist_filters="false"/>
</service>
.. code-block:: yaml
# config/services.yaml
Expand All @@ -119,6 +108,17 @@ You can disable it per Admin if you want.
tags:
- { name: sonata.admin, manager_type: orm, persist_filters: false }
.. code-block:: xml
<!-- config/services.xml -->
<service id="app.admin.user" class="App\Admin\UserAdmin">
<argument/>
<argument>App\Entity\User</argument>
<argument/>
<tag name="sonata.admin" manager_type="orm" persist_filters="false"/>
</service>
.. note::

Both ``persist_filters`` and ``filter_persister`` can be used globally
Expand Down
108 changes: 54 additions & 54 deletions docs/reference/advanced_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@ With a tag attribute (less verbose)

.. configuration-block::

.. code-block:: yaml
# config/services.yaml
app.admin.project:
class: App\Admin\ProjectAdmin
arguments:
- ~
- App\Entity\Project
- ~
tags:
-
name: sonata.admin
manager_type: orm
group: 'Project'
label: 'Project'
label_translator_strategy: 'sonata.admin.label.strategy.native'
route_builder: 'sonata.admin.route.path_info'
.. code-block:: xml
<!-- config/services.xml -->
Expand All @@ -56,6 +75,11 @@ With a tag attribute (less verbose)
/>
</service>
With a method call (more verbose)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. configuration-block::

.. code-block:: yaml
# config/services.yaml
Expand All @@ -66,19 +90,11 @@ With a tag attribute (less verbose)
- ~
- App\Entity\Project
- ~
calls:
- [setLabelTranslatorStrategy, ['@sonata.admin.label.strategy.native']]
- [setRouteBuilder, ['@sonata.admin.route.path_info']]
tags:
-
name: sonata.admin
manager_type: orm
group: 'Project'
label: 'Project'
label_translator_strategy: 'sonata.admin.label.strategy.native'
route_builder: 'sonata.admin.route.path_info'
With a method call (more verbose)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. configuration-block::
- { name: sonata.admin, manager_type: orm, group: 'Project', label: 'Project' }
.. code-block:: xml
Expand All @@ -97,22 +113,6 @@ With a method call (more verbose)
<tag name="sonata.admin" manager_type="orm" group="Project" label="Project"/>
</service>
.. code-block:: yaml
# config/services.yaml
app.admin.project:
class: App\Admin\ProjectAdmin
arguments:
- ~
- App\Entity\Project
- ~
calls:
- [setLabelTranslatorStrategy, ['@sonata.admin.label.strategy.native']]
- [setRouteBuilder, ['@sonata.admin.route.path_info']]
tags:
- { name: sonata.admin, manager_type: orm, group: 'Project', label: 'Project' }
If you want to modify the service that is going to be injected, add the following code to your
application's config file:

Expand Down Expand Up @@ -161,14 +161,6 @@ To create your own RouteBuilder create the PHP class and register it as a servic

.. configuration-block::

.. code-block:: xml
<!-- config/services.xml -->
<service id="app.admin.entity_route_builder" class="App\Route\EntityRouterBuilder">
<argument type="service" id="sonata.admin.audit.manager"/>
</service>
.. code-block:: yaml
# config/services.yaml
Expand All @@ -177,7 +169,15 @@ To create your own RouteBuilder create the PHP class and register it as a servic
app.admin.entity_route_builder:
class: App\Route\EntityRouterBuilder
arguments:
- "@sonata.admin.audit.manager"
- '@sonata.admin.audit.manager'
.. code-block:: xml
<!-- config/services.xml -->
<service id="app.admin.entity_route_builder" class="App\Route\EntityRouterBuilder">
<argument type="service" id="sonata.admin.audit.manager"/>
</service>
Inherited classes
-----------------
Expand All @@ -188,23 +188,6 @@ Lets consider a base class named `Person` and its subclasses `Student` and `Teac

.. configuration-block::

.. code-block:: xml
<!-- config/services.xml -->
<service id="app.admin.person" class="App\Admin\PersonAdmin">
<argument/>
<argument>App\Entity\Person</argument>
<argument></argument>
<call method="setSubClasses">
<argument type="collection">
<argument key="student">App\Entity\Student</argument>
<argument key="teacher">App\Entity\Teacher</argument>
</argument>
</call>
<tag name="sonata.admin" manager_type="orm" group="admin" label="Person"/>
</service>
.. code-block:: yaml
# config/services.yaml
Expand All @@ -224,6 +207,23 @@ Lets consider a base class named `Person` and its subclasses `Student` and `Teac
tags:
- { name: sonata.admin, manager_type: orm, group: "admin", label: "Person" }
.. code-block:: xml
<!-- config/services.xml -->
<service id="app.admin.person" class="App\Admin\PersonAdmin">
<argument/>
<argument>App\Entity\Person</argument>
<argument></argument>
<call method="setSubClasses">
<argument type="collection">
<argument key="student">App\Entity\Student</argument>
<argument key="teacher">App\Entity\Teacher</argument>
</argument>
</call>
<tag name="sonata.admin" manager_type="orm" group="admin" label="Person"/>
</service>
You will need to change the way forms are configured in order to
take into account these new subclasses::

Expand Down
48 changes: 24 additions & 24 deletions docs/reference/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ your ``Admin`` services. This is done using a ``call`` to the matching ``setter`

.. configuration-block::

.. code-block:: xml
<service id="app.admin.post" class="App\Admin\PostAdmin">
<argument/>
<argument>App\Entity\Post</argument>
<argument/>
<call method="setLabelTranslatorStrategy">
<argument type="service" id="sonata.admin.label.strategy.underscore"/>
</call>
<tag name="sonata.admin" manager_type="orm" group="Content" label="Post"/>
</service>
.. code-block:: yaml
services:
Expand All @@ -90,6 +78,18 @@ your ``Admin`` services. This is done using a ``call`` to the matching ``setter`
tags:
- { name: sonata.admin, manager_type: orm, group: 'Content', label: 'Post' }
.. code-block:: xml
<service id="app.admin.post" class="App\Admin\PostAdmin">
<argument/>
<argument>App\Entity\Post</argument>
<argument/>
<call method="setLabelTranslatorStrategy">
<argument type="service" id="sonata.admin.label.strategy.underscore"/>
</call>
<tag name="sonata.admin" manager_type="orm" group="Content" label="Post"/>
</service>
Here, we declare the same ``Admin`` service as in the :doc:`../getting_started/creating_an_admin`
chapter, but using a different label translator strategy, replacing the default one. Notice that
``sonata.admin.label.strategy.underscore`` is a service provided by ``SonataAdminBundle``,
Expand Down Expand Up @@ -119,18 +119,6 @@ to set the controller to ``App\Controller\PostAdminController``:

.. configuration-block::

.. code-block:: xml
<service id="app.admin.post" class="App\Admin\PostAdmin">
<argument/>
<argument>App\Entity\Post</argument>
<argument>App\Controller\PostAdminController</argument>
<call method="setTranslationDomain">
<argument>App</argument>
</call>
<tag name="sonata.admin" manager_type="orm" group="Content" label="Post"/>
</service>
.. code-block:: yaml
services:
Expand All @@ -145,6 +133,18 @@ to set the controller to ``App\Controller\PostAdminController``:
tags:
- { name: sonata.admin, manager_type: orm, group: 'Content', label: 'Post' }
.. code-block:: xml
<service id="app.admin.post" class="App\Admin\PostAdmin">
<argument/>
<argument>App\Entity\Post</argument>
<argument>App\Controller\PostAdminController</argument>
<call method="setTranslationDomain">
<argument>App</argument>
</call>
<tag name="sonata.admin" manager_type="orm" group="Content" label="Post"/>
</service>
When extending ``CRUDController``, remember that the ``Admin`` class already has
a set of automatically injected dependencies that are useful when implementing several
scenarios. Refer to the existing ``CRUDController`` actions for examples of how to get
Expand Down

0 comments on commit ce5dd00

Please sign in to comment.