|
@@ -316,26 +316,26 @@ template files, administration panel title and logo.
|
|
|
Create child admins
|
|
|
-------------------
|
|
|
|
|
|
-Let us say you have a ``PostAdmin`` and a ``CommentAdmin``. You can optionally declare the ``CommentAdmin``
|
|
|
-to be a child of the ``PostAdmin``. This will create new routes like, for example, ``/post/{id}/comment/list``,
|
|
|
-where the comments will automatically be filtered by post.
|
|
|
+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 PostAdmin service configuration :
|
|
|
+To do this, you first need to call the ``addChild`` method in your ``PlaylistAdmin`` service configuration:
|
|
|
|
|
|
.. configuration-block::
|
|
|
|
|
|
.. code-block:: xml
|
|
|
|
|
|
<!-- app/config/config.xml -->
|
|
|
- <service id="sonata.news.admin.post" class="AppBundle\Admin\PostAdmin">
|
|
|
+ <service id="sonata.admin.playlist" class="AppBundle\Admin\PlaylistAdmin">
|
|
|
<!-- ... -->
|
|
|
|
|
|
<call method="addChild">
|
|
|
- <argument type="service" id="sonata.news.admin.comment" />
|
|
|
+ <argument type="service" id="sonata.admin.video" />
|
|
|
</call>
|
|
|
</service>
|
|
|
|
|
|
-Then, you have to set the CommentAdmin ``parentAssociationMapping`` attribute to ``post`` :
|
|
|
+Then, you have to set the VideoAdmin ``parentAssociationMapping`` attribute to ``playlist`` :
|
|
|
|
|
|
.. code-block:: php
|
|
|
|
|
@@ -345,19 +345,19 @@ Then, you have to set the CommentAdmin ``parentAssociationMapping`` attribute to
|
|
|
|
|
|
// ...
|
|
|
|
|
|
- class CommentAdmin extends AbstractAdmin
|
|
|
+ class VideoAdmin extends AbstractAdmin
|
|
|
{
|
|
|
- protected $parentAssociationMapping = 'post';
|
|
|
+ protected $parentAssociationMapping = 'playlist';
|
|
|
|
|
|
// OR
|
|
|
|
|
|
public function getParentAssociationMapping()
|
|
|
{
|
|
|
- return 'post';
|
|
|
+ return 'playlist';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-To display the ``CommentAdmin`` extend the menu in your ``PostAdmin`` class:
|
|
|
+To display the ``VideoAdmin`` extend the menu in your ``PlaylistAdmin`` class:
|
|
|
|
|
|
.. code-block:: php
|
|
|
|
|
@@ -365,28 +365,28 @@ To display the ``CommentAdmin`` extend the menu in your ``PostAdmin`` class:
|
|
|
|
|
|
namespace AppBundle\Admin;
|
|
|
|
|
|
- class PostAdmin extends Admin
|
|
|
+ class PlaylistAdmin extends Admin
|
|
|
{
|
|
|
// ...
|
|
|
|
|
|
protected function configureTabMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
|
|
|
{
|
|
|
if (!$childAdmin && !in_array($action, array('edit', 'show'))) {
|
|
|
-
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$admin = $this->isChild() ? $this->getParent() : $this;
|
|
|
$id = $admin->getRequest()->get('id');
|
|
|
|
|
|
- $menu->addChild('Show Post', array('uri' => $admin->generateUrl('show', array('id' => $id))));
|
|
|
+ $menu->addChild('View Playlist', array('uri' => $admin->generateUrl('show', array('id' => $id))));
|
|
|
+
|
|
|
if (is_granted('EDIT') {
|
|
|
- $menu->addChild('Edit Post', array('uri' => $admin->generateUrl('edit', array('id' => $id))));
|
|
|
+ $menu->addChild('Edit Playlist', array('uri' => $admin->generateUrl('edit', array('id' => $id))));
|
|
|
}
|
|
|
|
|
|
if (is_granted('LIST', $admin) {
|
|
|
- $menu->addChild('Manage Comments', array(
|
|
|
- 'uri' => $admin->generateUrl('sonata.news.admin.comment.list', array('id' => $id))
|
|
|
+ $menu->addChild('Manage Videos', array(
|
|
|
+ 'uri' => $admin->generateUrl('sonata.admin.video.list', array('id' => $id))
|
|
|
));
|
|
|
}
|
|
|
}
|