| Conditions | 5 |
| Paths | 1 |
| Total Lines | 27 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function configureOptions(OptionsResolver $resolver): void |
||
| 16 | { |
||
| 17 | $resolver |
||
| 18 | ->setDefaults([ |
||
| 19 | 'template' => '@LAGAdmin/fields/action.html.twig', |
||
| 20 | 'translation' => true, |
||
| 21 | 'property_path' => null, |
||
| 22 | ]) |
||
| 23 | ->addNormalizer('attr', function (Options $options, $value) { |
||
| 24 | if (!empty($value['class'])) { |
||
| 25 | return $value; |
||
| 26 | } |
||
| 27 | $action = null; |
||
| 28 | |||
| 29 | if ($options->offsetExists('action')) { |
||
| 30 | $action = $options->offsetGet('action'); |
||
| 31 | } |
||
| 32 | |||
| 33 | if ('update' === $action) { |
||
| 34 | $value['class'] = 'btn btn-primary btn-sm'; |
||
| 35 | } elseif ('delete' === $action) { |
||
| 36 | $value['class'] = 'btn btn-danger btn-sm'; |
||
| 37 | } else { |
||
| 38 | $value['class'] = 'btn btn-secondary btn-sm'; |
||
| 39 | } |
||
| 40 | |||
| 41 | return $value; |
||
| 42 | }) |
||
| 46 |