| Conditions | 5 |
| Paths | 1 |
| Total Lines | 42 |
| Code Lines | 22 |
| Lines | 30 |
| Ratio | 71.43 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function configureOptions(OptionsResolver $resolver) |
||
| 17 | { |
||
| 18 | // menu html attributes |
||
| 19 | $resolver |
||
| 20 | ->setDefault('attr', []) |
||
| 21 | View Code Duplication | ->setNormalizer('attr', function(Options $options, $attr) { |
|
| 22 | |||
| 23 | if (!is_array($attr)) { |
||
| 24 | $attr = []; |
||
| 25 | } |
||
| 26 | |||
| 27 | if (empty($attr['id'])) { |
||
| 28 | $attr['id'] = uniqid('admin-menu-'); |
||
| 29 | } |
||
| 30 | |||
| 31 | return $attr; |
||
| 32 | }) |
||
| 33 | ; |
||
| 34 | |||
| 35 | // menu item |
||
| 36 | $resolver |
||
| 37 | ->setDefault('items', []) |
||
| 38 | View Code Duplication | ->setNormalizer('items', function(Options $options, $items) { |
|
| 39 | |||
| 40 | if (!is_array($items)) { |
||
| 41 | $items = []; |
||
| 42 | } |
||
| 43 | $resolver = new OptionsResolver(); |
||
| 44 | $resolvedItems = []; |
||
| 45 | |||
| 46 | foreach ($items as $name => $item) { |
||
| 47 | $itemConfiguration = new MenuItemConfiguration(); |
||
| 48 | $itemConfiguration->configureOptions($resolver); |
||
| 49 | $itemConfiguration->setParameters($resolver->resolve($item)); |
||
| 50 | |||
| 51 | $resolvedItems[$name] = $itemConfiguration; |
||
| 52 | } |
||
| 53 | |||
| 54 | return $resolvedItems; |
||
| 55 | }) |
||
| 56 | ; |
||
| 57 | } |
||
| 58 | } |
||
| 59 |