add batch action

This commit is contained in:
Simon Vieille 2022-02-19 15:50:39 +01:00
parent b839f4df0b
commit e0b4206778

View file

@ -20,6 +20,7 @@ use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Form\Form;
use App\Core\Entity\EntityInterface;
use App\Entity\Blog\Post;
/**
* @Route("/admin/blog/post")
@ -84,6 +85,12 @@ class PostAdminController extends CrudController
->setBatchAction('index', 'delete', 'Delete', function(EntityInterface $entity, EntityManager $manager) {
$manager->delete($entity);
})
->setBatchAction('index', 'draft', 'Publier', function(EntityInterface $entity, EntityManager $manager) {
$manager->update($entity->setStatus(Post::DRAFT));
})
->setBatchAction('index', 'publish', 'En brouillon', function(EntityInterface $entity, EntityManager $manager) {
$manager->update($entity->setStatus(Post::PUBLISHED));
})
;
}