EasyCorp / EasyCorp/EasyAdminBundle
global batch action giving crudControllerFqcn null error
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 4.3k
- Forks
- 1.1k
- Avg merge
- 8d 2h
- Merged PRs (30d)
- 11
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());
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ArgumentResolver/BatchActionDtoResolver.php at line 65 and the AdminUrlGenerator::setController() call, then reproduce the global batch action using the ListingCrudController example. Trace why the batch action has no CRUD controller and add or update a regression test so the action completes without passing null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, symfony
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100