| Conditions | 3 |
| Paths | 3 |
| Total Lines | 31 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | public function handle(FormInterface $form, AdminInterface $admin) |
||
| 35 | { |
||
| 36 | $generator = new RouteNameGenerator(); |
||
| 37 | |||
| 38 | if ($form->isValid()) { |
||
| 39 | // remove the current entity |
||
| 40 | $admin->remove(); |
||
| 41 | |||
| 42 | // redirect to list if the action exist |
||
| 43 | $allowedActions = $admin |
||
| 44 | ->getConfiguration() |
||
| 45 | ->getParameter('actions') |
||
| 46 | ; |
||
| 47 | |||
| 48 | if (array_key_exists('list', $allowedActions)) { |
||
| 49 | $url = $this |
||
| 50 | ->router |
||
| 51 | ->generate($generator->generate('list', $admin->getName(), $admin->getConfiguration())) |
||
| 52 | ; |
||
| 53 | |||
| 54 | return new RedirectResponse($url); |
||
| 55 | } |
||
| 56 | return new RedirectResponse('/'); |
||
| 57 | } |
||
| 58 | $url = $this |
||
| 59 | ->router |
||
| 60 | ->generate($generator->generate('delete', $admin->getName(), $admin->getConfiguration())) |
||
| 61 | ; |
||
| 62 | |||
| 63 | return new RedirectResponse($url); |
||
| 64 | } |
||
| 65 | } |
||
| 66 |