Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Delete | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __invoke | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Controller\Deposits; |
| 6 | |
| 7 | use App\Controller\BaseController; |
| 8 | use App\Entity\Deposit; |
| 9 | use Doctrine\ORM\EntityManagerInterface; |
| 10 | use Symfony\Component\HttpFoundation\RedirectResponse; |
| 11 | use Symfony\Component\Routing\Attribute\Route; |
| 12 | use Symfony\Component\Security\Http\Attribute\IsGranted; |
| 13 | |
| 14 | #[IsGranted('ROLE_ADMIN')] |
| 15 | #[Route(path: '/deposits/delete/{id}', name: 'deposits_delete', methods: ['GET'])] |
| 16 | class Delete extends BaseController |
| 17 | { |
| 18 | public function __invoke( |
| 19 | Deposit $deposit, |
| 20 | EntityManagerInterface $entityManager, |
| 21 | ): RedirectResponse |
| 22 | { |
| 23 | $entityManager->remove($deposit); |
| 24 | $entityManager->flush(); |
| 25 | $this->addFlash('success', 'Deposit method has been deleted'); |
| 26 | |
| 27 | return $this->redirectToRoute('deposits_index'); |
| 28 | } |
| 29 | } |