I am trying to inject doctrine service (if there is a way to inject BoothTypeRepository without Doctrine, that's also fine) into configureActionButtons and I can't find the way to inject nor doctrine or 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;
}
The Error which I got from the upper code
An exception has been thrown during the rendering of a template ("Class "App\Repository\BoothTypeRepository" sub class of "Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository" is not a valid entity or mapped super class.").
This is the namespace for BoothTypeRepository ->
namespace App\Repository;