3

I have been trying to install SonataAdminBundle. I think I followed the documentation, plus I read some blogs about it. But I couldn't do it.

When going to the admin/dashboard page, i see the Sonata Title, i can see the sonata.block.service.text and the sonata.block.service.rss on the right, but there is nothing in the admin_list block => I can't see my Entity.

Here is how I set it up. I maybe forgot something ? Here is the app/config/config.yml

imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: ../../src/Pierre/TennisBundle/Resources/config/admin.yml }

...

sonata_block:
    default_contexts: [cms]
    blocks:
        sonata.admin.block.admin_list:
            contexts:   [admin]

        sonata.block.service.text:
        sonata.block.service.rss:

sonata_doctrine_orm_admin:
    # default value is null, so doctrine uses the value defined in the configuration
    entity_manager: '@doctrine.orm.entity_manager'

    templates:
        form:
            - SonataDoctrineORMAdminBundle:Form:form_admin_fields.html.twig
        filter:
        - SonataDoctrineORMAdminBundle:Form:filter_admin_fields.html.twig
        types:
            list:
                array:      SonataAdminBundle:CRUD:list_array.html.twig
                boolean:    SonataAdminBundle:CRUD:list_boolean.html.twig
                date:       SonataAdminBundle:CRUD:list_date.html.twig
                time:       SonataAdminBundle:CRUD:list_time.html.twig
                datetime:   SonataAdminBundle:CRUD:list_datetime.html.twig
                text:       SonataAdminBundle:CRUD:base_list_field.html.twig
                trans:      SonataAdminBundle:CRUD:list_trans.html.twig
                string:     SonataAdminBundle:CRUD:base_list_field.html.twig
                smallint:   SonataAdminBundle:CRUD:base_list_field.html.twig
                bigint:     SonataAdminBundle:CRUD:base_list_field.html.twig
                integer:    SonataAdminBundle:CRUD:base_list_field.html.twig
                decimal:    SonataAdminBundle:CRUD:base_list_field.html.twig
                identifier: SonataAdminBundle:CRUD:base_list_field.html.twig

            show:
                array:      SonataAdminBundle:CRUD:show_array.html.twig
                boolean:    SonataAdminBundle:CRUD:show_boolean.html.twig
                date:       SonataAdminBundle:CRUD:show_date.html.twig
                time:       SonataAdminBundle:CRUD:show_time.html.twig
                datetime:   SonataAdminBundle:CRUD:show_datetime.html.twig
                text:       SonataAdminBundle:CRUD:base_show_field.html.twig
                trans:      SonataAdminBundle:CRUD:show_trans.html.twig
                string:     SonataAdminBundle:CRUD:base_show_field.html.twig
                smallint:   SonataAdminBundle:CRUD:base_show_field.html.twig
                bigint:     SonataAdminBundle:CRUD:base_show_field.html.twig
                integer:    SonataAdminBundle:CRUD:base_show_field.html.twig
                decimal:    SonataAdminBundle:CRUD:base_show_field.html.twig

sonata_admin:
    security:
        handler: sonata.admin.security.handler.role

    title:      Sonata Project
    title_logo: /bundles/sonataadmin/logo_title.png
    templates:
        # default global templates
        layout:  SonataAdminBundle::standard_layout.html.twig
        ajax:    SonataAdminBundle::ajax_layout.html.twig
        dashboard: SonataAdminBundle:Core:dashboard.html.twig

        # default actions templates, should extend a global templates
        list:    SonataAdminBundle:CRUD:list.html.twig
        show:    SonataAdminBundle:CRUD:show.html.twig
        edit:    SonataAdminBundle:CRUD:edit.html.twig

    dashboard:
        blocks:
            # display a dashboard block
            - { position: left, type: sonata.admin.block.admin_list }

            # Customize this part to add new block configuration
            - { position: right, type: sonata.block.service.text, settings: { content: "<h2>Welcome to the Sonata Admin</h2> <p>This is a <code>sonata.block.service.text</code> from the Block Bundle, you can create and add new block in these area by configuring the <code>sonata_admin</code> section.</p> <br /> For instance, here a RSS feed parser (<code>sonata.block.service.rss</code>):"} }
            - { position: right, type: sonata.block.service.rss, settings: { title: Sonata Project's Feeds, url: http://sonata-project.org/blog/archive.rss }}

        groups:
            sonata_page:
                label: TestLabel
                items: ~



    # set to true to persist filter settings per admin module in the user's session
    persist_filters: true

My admin class

namespace Pierre\TennisBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;

use Pierre\TennisBundle\Entity\Tennismen;

class TennismenAdmin extends Admin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('name')
               ;
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('name')
               ;
    }

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('name')
                ;
    }
}

My Controller:

namespace Pierre\TennisBundle\Controller;

use Sonata\AdminBundle\Controller\CRUDController as Controller;

class TennismenAdminController extends Controller
{
}

And my service:

# TennisBundle/Resources/config/admin.yml
services:
    pierre.tennis.admin.tennismen:
        class: Pierre\TennisBundle\Admin\TennismenAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, group: sonata_page, label: Blog }
        arguments: [null, Pierre\TennisBundle\Entity\Tennismen, PierreTennisBundle:TennismenAdmin]

So I think i respected the guide... but I can't see my Entity Tennismen in the dashboard.

3 Answers 3

4

But in some cases granting SUPER_ADMIN role to all users is not a solution, make sure you have this line in yout parameters.yml :

security.acl.permission.map.class: Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap
0
2

Can you try SonataAdminBundle:CRUD as your third argument in the service definition? Also, ensure you have logged in with super admin (if you have SonataUserAdmin installed). Also, try removing dashboard part in your config.yml or try using as little configuration as possible all together.

1
  • Hi, thanks for your attention. I have tried both but it still doesn't show anything. I am not using SonataUser, but i have installed FOSuser. WOuld it be a ROLE thing ? do you know what Role should I have ?
    – Pierrito
    Jul 28, 2013 at 20:25
0

I Could solve it thanks to you ! I had to add the FOSUser SUPER_ADMIN role to my user to be able to see the admin_block.

Thanks!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.