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 | declare(strict_types=1); |
| 3 | |
| 4 | namespace App\Controller\Contracts; |
| 5 | |
| 6 | use App\Controller\BaseController; |
| 7 | use App\Entity\Contract; |
| 8 | use Doctrine\ORM\EntityManagerInterface; |
| 9 | use Symfony\Component\HttpFoundation\RedirectResponse; |
| 10 | use Symfony\Component\Routing\Attribute\Route; |
| 11 | use Symfony\Component\Security\Http\Attribute\IsGranted; |
| 12 | |
| 13 | #[IsGranted('ROLE_ADMIN')] |
| 14 | #[Route(path: '/contracts/delete/{id}', name: 'contracts_delete', methods: ['GET'])] |
| 15 | class Delete extends BaseController |
| 16 | { |
| 17 | public function __invoke( |
| 18 | Contract $contract, |
| 19 | EntityManagerInterface $entityManager, |
| 20 | ): RedirectResponse |
| 21 | { |
| 22 | $entityManager->remove($contract); |
| 23 | $entityManager->flush(); |
| 24 | $this->addFlash('success', 'Contract has been deleted'); |
| 25 | |
| 26 | return $this->redirectToRoute('contracts_index'); |
| 27 | } |
| 28 | } |