<commit_before>Create child admins
-------------------

.. note::
    This article assumes you are using Symfony 4. Using Symfony 2.8 or 3
    will require to slightly modify some namespaces and paths when creating
    entities and admins.

Let us say you have a ``PlaylistAdmin`` and a ``VideoAdmin``. You can
optionally declare the ``VideoAdmin`` to be a child of the ``PlaylistAdmin``.
This will create new routes like, for example, ``/playlist/{id}/video/list``,
where the videos will automatically be filtered by post.

To do this, you first need to call the ``addChild`` method in your ``PlaylistAdmin``
service configuration with two arguments, the child admin name (in this case
``VideoAdmin`` service) and the Entity field that relates our child Entity with
its parent:

.. configuration-block::

    .. code-block:: xml

        <!-- app/config/config.xml -->
        <service id="sonata.admin.playlist" class="App\Admin\PlaylistAdmin">
            <!-- ... -->

            <call method="addChild">
                <argument type="service" id="sonata.admin.video" />
                <argument>playlist</argument>
            </call>
        </service>

To display the ``VideoAdmin`` extend the menu in your ``PlaylistAdmin``
class::

    <?php

    namespace App\Admin;

    use Knp\Menu\ItemInterface as MenuItemInterface;
    use Sonata\AdminBundle\Admin\AbstractAdmin;
    use Sonata\AdminBundle\Admin\AdminInterface;<commit_msg>Updated docs for children admins (#5115)<commit_after>Create child admins
-------------------

.. note::
    This article assumes you are using Symfony 4. Using Symfony 2.8 or 3
    will require to slightly modify some namespaces and paths when creating
    entities and admins.

Let us say you have a ``PlaylistAdmin`` and a ``VideoAdmin``. You can
optionally declare the ``VideoAdmin`` to be a child of the ``PlaylistAdmin``.
This will create new routes like, for example, ``/playlist/{id}/video/list``,
where the videos will automatically be filtered by post.

To do this, you first need to call the ``addChild`` method in your ``PlaylistAdmin``
service configuration with two arguments, the child admin name (in this case
``VideoAdmin`` service) and the Entity field that relates our child Entity with
its parent:

.. configuration-block::

    .. code-block:: yaml

        # app/config/services.yml
        App\Admin\PlaylistAdmin:
            calls:
                - [ addChild, ['@App\Admin\VideoAdmin', 'playlist']]

    .. code-block:: xml

        <!-- app/config/services.xml -->
        <service id="App\Admin\PlaylistAdmin">
            <!-- ... -->

            <call method="addChild">
                <argument type="service" id="App\Admin\PlaylistAdmin" />
                <argument>playlist</argument>
            </call>
        </service>

To display the ``VideoAdmin`` extend the menu in your ``PlaylistAdmin``
class::

    <?php

    namespace App\Admin;

    use Knp\Menu\ItemInterface as MenuItemInterface;
    use Sonata\AdminBundle\Admin\AbstractAdmin;
    use Sonata\AdminBundle\Admin\AdminInterface;
{'fraction_non_alphanumeric': 0.1201171875, 'fraction_numerical': 0.00390625, 'mean_word_length': 2.793827160493827, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6014152', 'n_tokens_mistral': 837, 'n_tokens_neox': 804, 'n_words': 309}