-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Describe the bug
EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator::setController(): Argument #1 ($crudControllerFqcn) must be of type string, null given, called in /home/shivansh/Workspace/brokertruf/vendor/easycorp/easyadmin-bundle/src/ArgumentResolver/BatchActionDtoResolver.php on line 65
To Reproduce
try to create global batch action
<?php
namespace App\Controller\Admin;
use App\Entity\Listing;
use EasyCorp\Bundle\EasyAdminBundle\Attribute\AdminAction;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Dto\BatchActionDto;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Response;
class ListingCrudController extends AbstractCrudController
{
public function __construct(
private EntityManagerInterface $entityManager
) {}
public static function getEntityFqcn(): string
{
return Listing::class;
}
public function configureActions(Actions $actions): Actions
{
$batchUpdate = Action::new('batchUpdate', 'Update Age')
->linkToCrudAction('batchUpdate')
->addCssClass('btn btn-primary')
->setIcon('fa fa-clock');
return $actions
->addBatchAction($batchUpdate);
}
public function batchUpdate(BatchActionDto $batchActionDto): Response
{
$entityIds = $batchActionDto->getEntityIds();
try {
$qb = $this->entityManager->createQueryBuilder();
$qb->update($batchActionDto->getEntityFqcn(), 'e')
->set('e.ageOfListing', ':now')
->where($qb->expr()->in('e.id', ':ids'))
->setParameter('now', new \DateTimeImmutable('now'))
->setParameter('ids', $entityIds)
->getQuery()
->execute();
$this->addFlash('success', sprintf('%d listing(s) updated.', count($entityIds)));
} catch (\Exception $e) {
$this->addFlash('error', 'Update failed.');
}
return $this->redirect($batchActionDto->getReferrerUrl());
}
}Metadata
Metadata
Assignees
Labels
No labels