显示奏鸣曲mongodb管理包

时间:2015-05-04 15:34:43

标签: mongodb symfony sonata-admin

我正在我的项目中添加Sonata mongoDB管理包,在完成所有配置后,似乎捆绑工作正常但是有一个问题它不显示应该显示的文档列表。 当我去/ admin我找到奏鸣曲管理员模板但我把它弄空了。这是我的config.yml:

sonata_block:
default_contexts: [cms]
blocks:
    # Enable the SonataAdminBundle block
    sonata.admin.block.admin_list:
        contexts:   [admin]



sonata_doctrine_mongo_db_admin:
templates:
    form:
        - SonataDoctrineMongoDBAdminBundle:Form:form_admin_fields.html.twig
    filter:
        - SonataDoctrineMongoDBAdminBundle: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

这是我的admin.yml(我按照文档说明):

services:
sonata.admin.question:
    class: ATS\AdminBundle\Admin\questionAdmin
    tags:
        - { name: sonata.admin, manager_type: doctrine_mongodb, group: "Content", label: "Question" }
    arguments:
        - ~
        - ATS\QuizzBundle\Document\Question
        - ~
    calls:
        - [ setTranslationDomain, [ATSAdminBundle]]

最后这里是我的问题管理类(直到这里我只需要显示存储在数据库中的问题列表):

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

class questionAdmin extends Admin
{
// Fields to be shown on create/edit forms
protected function configureListFields(ListMapper $listMapper)
{
    $listMapper
    ->addIdentifier('question')
    ->add('weight')

        // ->add('tags')
        // ->add('commentsEnabled')

        //add custom action links
    ->add('_action', 'actions', array(
        'actions' => array(
            'view' => array(),
            'edit' => array(),
            )
        ))
    ;
}

任何人都有解决方案?谢谢

0 个答案:

没有答案