我试图在Sonata-Admin中创建自定义表单并且正在设置没有为类School. ChildBirthBundle \ Entity \ DataChapter定义的实体管理器
我的代码:
namespace School\ChildBirthBundle\Admin;
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;
use Knp\Menu\ItemInterface as MenuItemInterface;
use School\ChildBirthBundle\Entity\DataChapter;
class DataChapterAdmin extends Admin
{
protected function configureShowFields(ShowMapper $showMapper)
{
$showMapper
->add('name')
->add('status')
;
}
sonata.admin.data_chapter:
class: School\ChildBirthBundle\Admin\DataChapterAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "Content", label: "Chapter" }
arguments:
- ~
- School\ChildBirthBundle\Entity\DataChapter
- ~
- @doctrine.orm.default_entity_manager
calls:
- [ setTranslationDomain, [SchoolChildBirthBundle]]
实体看起来像这样
namespace School\ChildBirthBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="data_chapter")
*/
class DataChapter
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=255)
*/
protected $name;
/**
* @ORM\Column(type="integer", length=1)
*/
protected $status;
/**
* @ORM\Column(type="integer")
*/
protected $idSubject;
}
我不知道我做错了什么
答案 0 :(得分:0)
没有为School \ ChildBirthBundle \ Entity \ DataChapter类定义实体管理器 500内部服务器错误 - RuntimeException
in vendor/sonata-project/doctrine-orm-admin-bundle/Model/ModelManager.php at line 223 -
$em = $this->registry->getManagerForClass($class);
if (!$em) {
throw new \RuntimeException(sprintf('No entity manager defined for class %s', $class));
}
$this->cache[$class] = $em;
答案 1 :(得分:0)
也许这是您的管理服务声明中的一个问题,如果您查看文档没有第四个参数:
你应该:
sonata.admin.data_chapter:
class: School\ChildBirthBundle\Admin\DataChapterAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "Content", label: "Chapter" }
arguments:
- ~
- School\ChildBirthBundle\Entity\DataChapter
- ~
calls:
- [ setTranslationDomain, [SchoolChildBirthBundle]]