几天来我一直在寻找问题所在;我按照奏鸣曲网站上的文档重复了几次,但我的仪表板仍然是空的。在编写了我的AdminClass
and Services
(并设置config.yml
了admin
.
这是我的代码App/Config/Config.yml
(导入文件顶部)
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: @materniteamAppBundle/Resources/config/admin.yml }
- { resource: @materniteamUserBundle/Resources/config/admin.yml }
App/Config/Config.yml
(带有奏鸣曲配置的文件底部)
# FOS USER
fos_user:
db_driver: orm
firewall_name: main
user_class: materniteam\UserBundle\Entity\User
# ADMIN SONATA
sonata_block:
default_contexts: [cms]
blocks:
sonata.admin.block.admin_list:
contexts: [admin]
sonata.block.service.text:
sonata.block.service.action:
sonata.block.service.rss:
sonata_admin:
title: Materniteam
security:
handler: sonata.admin.security.handler.role
acl_user_manager: fos_user.user_manager
这是我的实体联系人管理类//src/APP/APPBundle/Admin/ContactAdmin.php
:
<?php
namespace materniteam\AppBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;
class ContactAdmin extends Admin
{
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->with('General')
->add('prenom')
->add('nom')
->add('adresse')
->add('codePostal')
->add('ville')
->end()
;
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('Nom')
->add('prenom')
->add('adresse')
->add('codePostal')
->add('ville')
->add('_action', 'actions', array(
'actions' => array(
'view' => array(),
'edit' => array(),
'delete' => array(),
)
))
;
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('prenom')
->add('nom')
->add('adresse')
;
}
}
?>
最后这是我的服务电话//src/APP/APPBundle/Resources/config/admin.yml
services:
materniteam.app.admin.contact:
class: materniteam\AppBundle\Admin\ContactAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "App", label: "Contact" }
arguments: [ null, materniteam\AppBundle\Entity\Contact, SonataAdminBundle:CRUD ]
就像我说的,我没有错误,但仪表板仍然没有列出我的实体。如果您需要更多代码,请询问,我将编辑此消息。
如果任何奏鸣曲乐队成员正在阅读此内容:
请更新您的文件!!!