【发布时间】:2021-11-09 03:29:32
【问题描述】:
我正在尝试向configureActionButtons 注入教义服务(如果有一种方法可以在没有 Doctrine 的情况下注入 BoothTypeRepository,那也可以),但我找不到注入或教义或 BoothTypeRepository 的方法。
public function configureActionButtons($action, $object = null): array
{
$list = parent::configureActionButtons($action, $object);;
$handles = $this->getConfigurationPool()->getContainer()->get('doctrine.orm.entity_manager')->getRepository(BoothTypeRepository::class)->findAll();
foreach($handles as $handle) {
$list['new_' . $handle] = [
'attr' => $handle,
'template' => 'CRUD/button_new_booth_type.html.twig'
];
}
unset($list['new']);
return $list;
}
我从上面的代码得到的错误
在渲染模板期间引发了异常 ("Class "App\Repository\BoothTypeRepository" 的子类 "Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository" 是 不是有效的实体或映射的超类。”)。
这是BoothTypeRepository 的命名空间 -> namespace App\Repository;
【问题讨论】:
标签: symfony doctrine-orm sonata-admin sonata