| Conditions | 5 |
| Paths | 1 |
| Total Lines | 80 |
| Code Lines | 62 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 35 | public function configureOptions(OptionsResolver $resolver) |
||
| 36 | { |
||
| 37 | $resolver |
||
| 38 | ->setDefaults([ |
||
| 39 | // enable or disable extra configuration listener |
||
| 40 | 'enable_extra_configuration' => true, |
||
| 41 | 'enable_security' => true, |
||
| 42 | 'enable_menus' => true, |
||
| 43 | 'enable_homepage' => true, |
||
| 44 | 'title' => 'AdminBundle application', |
||
| 45 | 'description' => '', |
||
| 46 | 'locale' => 'en', |
||
| 47 | // Main base template as bundles are not loaded when reading the configuration, the kernel |
||
| 48 | // locateResources will always failed. So we must not check resource existence here. |
||
| 49 | 'base_template' => '@LAGAdmin/base.html.twig', |
||
| 50 | 'ajax_template' => '@LAGAdmin/empty.html.twig', |
||
| 51 | 'block_template' => '@LAGAdmin/Form/fields.html.twig', |
||
| 52 | 'menu_template' => '@LAGAdmin/Menu/menu.html.twig', |
||
| 53 | 'list_template' => '@LAGAdmin/CRUD/list.html.twig', |
||
| 54 | 'edit_template' => '@LAGAdmin/CRUD/edit.html.twig', |
||
| 55 | 'create_template' => '@LAGAdmin/CRUD/create.html.twig', |
||
| 56 | 'delete_template' => '@LAGAdmin/CRUD/delete.html.twig', |
||
| 57 | 'homepage_template' => '@LAGAdmin/Pages/home.html.twig', |
||
| 58 | 'homepage_route' => 'lag.admin.homepage', |
||
| 59 | 'routing_url_pattern' => '/{admin}/{action}', |
||
| 60 | 'routing_name_pattern' => 'lag.admin.{admin}.{action}', |
||
| 61 | 'bootstrap' => true, |
||
| 62 | 'date_format' => 'Y/m/d', |
||
| 63 | 'pager' => 'pagerfanta', |
||
| 64 | // string length before truncation (0 means no truncation) |
||
| 65 | 'string_length' => 200, |
||
| 66 | 'string_length_truncate' => '...', |
||
| 67 | 'max_per_page' => 20, |
||
| 68 | 'admin_class' => Admin::class, |
||
| 69 | 'action_class' => Action::class, |
||
| 70 | 'permissions' => 'ROLE_ADMIN', |
||
| 71 | 'page_parameter' => 'page', |
||
| 72 | ]) |
||
| 73 | ->setAllowedTypes('enable_extra_configuration', 'boolean') |
||
| 74 | ->setAllowedTypes('enable_security', 'boolean') |
||
| 75 | ->setAllowedTypes('enable_menus', 'boolean') |
||
| 76 | ->setAllowedTypes('title', 'string') |
||
| 77 | ->setAllowedTypes('description', 'string') |
||
| 78 | ->setAllowedTypes('locale', 'string') |
||
| 79 | ->setAllowedTypes('base_template', 'string') |
||
| 80 | ->setAllowedTypes('block_template', 'string') |
||
| 81 | ->setAllowedTypes('bootstrap', 'boolean') |
||
| 82 | ->setAllowedTypes('date_format', 'string') |
||
| 83 | ->setAllowedTypes('string_length', 'integer') |
||
| 84 | ->setAllowedTypes('string_length_truncate', 'string') |
||
| 85 | ->setAllowedTypes('max_per_page', 'integer') |
||
| 86 | ->setAllowedTypes('admin_class', 'string') |
||
| 87 | ->setAllowedTypes('routing_name_pattern', 'string') |
||
| 88 | ->setAllowedTypes('routing_url_pattern', 'string') |
||
| 89 | ->setAllowedTypes('page_parameter', 'string') |
||
| 90 | ->setNormalizer('routing_name_pattern', function (Options $options, $value) { |
||
| 91 | if (false === strstr($value, '{admin}')) { |
||
| 92 | throw new InvalidOptionsException('Admin routing configuration pattern name should contains the {admin} placeholder'); |
||
| 93 | } |
||
| 94 | if (false === strstr($value, '{action}')) { |
||
| 95 | throw new InvalidOptionsException('Admin routing configuration pattern name should contains the {action} placeholder'); |
||
| 96 | } |
||
| 97 | |||
| 98 | return $value; |
||
| 99 | }) |
||
| 100 | ->setNormalizer('routing_url_pattern', function (Options $options, $value) { |
||
| 101 | if (false === strstr($value, '{admin}')) { |
||
| 102 | throw new InvalidOptionsException('Admin routing configuration url pattern should contains {admin} placeholder'); |
||
| 103 | } |
||
| 104 | |||
| 105 | if (false === strstr($value, '{action}')) { |
||
| 106 | throw new InvalidOptionsException('Admin routing configuration url pattern should contains the {action} placeholder'); |
||
| 107 | } |
||
| 108 | |||
| 109 | return $value; |
||
| 110 | }) |
||
| 111 | ; |
||
| 112 | |||
| 113 | $this->setFieldsOptions($resolver); |
||
| 114 | $this->configureTranslation($resolver); |
||
| 115 | } |
||
| 161 |