| Conditions | 1 |
| Paths | 1 |
| Total Lines | 91 |
| Code Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 9 | ||
| 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 |
||
| 22 | public function register(Application $app) |
||
| 23 | { |
||
| 24 | $app->register(new MenuProvider()); |
||
| 25 | |||
| 26 | $app->register(new SaxulumUserProvider(), array( |
||
| 27 | 'saxulum.userprovider.userclass' => User::class, |
||
| 28 | )); |
||
| 29 | |||
| 30 | $app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig) { |
||
| 31 | $twig->addExtension(new FormLabelExtension()); |
||
| 32 | |||
| 33 | return $twig; |
||
| 34 | })); |
||
| 35 | |||
| 36 | $app['form.types'] = $app->share($app->extend('form.types', function ($types) use ($app) { |
||
| 37 | $types[] = new SimpleDateType(); |
||
| 38 | $types[] = new EntityType($app['doctrine']); |
||
| 39 | $types[] = new AjaxEntityType($app['doctrine']); |
||
| 40 | |||
| 41 | return $types; |
||
| 42 | })); |
||
| 43 | |||
| 44 | $app['security.voters'] = $app->share($app->extend('security.voters', function ($voters) use ($app) { |
||
| 45 | $voters[] = new RelatedObjectVoter( |
||
| 46 | new RoleHierarchy($app['security.role_hierarchy']), |
||
| 47 | $app['logger'] |
||
| 48 | ); |
||
| 49 | |||
| 50 | return $voters; |
||
| 51 | })); |
||
| 52 | |||
| 53 | $app['security.role_hierarchy'] = $app->share($app->extend('security.role_hierarchy', function ($roleHierarchy) use ($app) { |
||
| 54 | |||
| 55 | // comestible |
||
| 56 | $roleHierarchy['ROLE_COMESTIBLE_LIST'] = array(); |
||
| 57 | $roleHierarchy['ROLE_COMESTIBLE_CREATE'] = array('ROLE_COMESTIBLE_LIST'); |
||
| 58 | $roleHierarchy['RELATED_COMESTIBLE_EDIT'] = array('ROLE_COMESTIBLE_LIST'); |
||
| 59 | $roleHierarchy['RELATED_COMESTIBLE_VIEW'] = array('ROLE_COMESTIBLE_LIST'); |
||
| 60 | $roleHierarchy['RELATED_COMESTIBLE_DELETE'] = array('ROLE_COMESTIBLE_LIST'); |
||
| 61 | |||
| 62 | // day |
||
| 63 | $roleHierarchy['ROLE_DAY_LIST'] = array(); |
||
| 64 | $roleHierarchy['ROLE_DAY_CREATE'] = array('ROLE_DAY_LIST'); |
||
| 65 | $roleHierarchy['RELATED_DAY_EDIT'] = array('ROLE_DAY_LIST'); |
||
| 66 | $roleHierarchy['RELATED_DAY_VIEW'] = array('ROLE_DAY_LIST'); |
||
| 67 | $roleHierarchy['RELATED_DAY_DELETE'] = array('ROLE_DAY_LIST'); |
||
| 68 | |||
| 69 | $roleHierarchy[AbstractUser::ROLE_USER][] = 'ROLE_COMESTIBLE_CREATE'; |
||
| 70 | $roleHierarchy[AbstractUser::ROLE_USER][] = 'RELATED_COMESTIBLE_EDIT'; |
||
| 71 | $roleHierarchy[AbstractUser::ROLE_USER][] = 'RELATED_COMESTIBLE_VIEW'; |
||
| 72 | $roleHierarchy[AbstractUser::ROLE_USER][] = 'RELATED_COMESTIBLE_DELETE'; |
||
| 73 | |||
| 74 | $roleHierarchy[AbstractUser::ROLE_USER][] = 'ROLE_DAY_CREATE'; |
||
| 75 | $roleHierarchy[AbstractUser::ROLE_USER][] = 'RELATED_DAY_EDIT'; |
||
| 76 | $roleHierarchy[AbstractUser::ROLE_USER][] = 'RELATED_DAY_VIEW'; |
||
| 77 | $roleHierarchy[AbstractUser::ROLE_USER][] = 'RELATED_DAY_DELETE'; |
||
| 78 | |||
| 79 | return $roleHierarchy; |
||
| 80 | })); |
||
| 81 | |||
| 82 | $app['security.access_rules'] = $app->share($app->extend('security.access_rules', function ($rules) use ($app) { |
||
| 83 | $rules[] = array('^/_profiler*', 'IS_AUTHENTICATED_ANONYMOUSLY'); |
||
| 84 | $rules[] = array('^/[^/]+/login*', 'IS_AUTHENTICATED_ANONYMOUSLY'); |
||
| 85 | $rules[] = array('^/[^/]+/logout*', 'IS_AUTHENTICATED_ANONYMOUSLY'); |
||
| 86 | $rules[] = array('^/[^/]+/admin', 'ROLE_ADMIN'); |
||
| 87 | $rules[] = array('^/[^/]+', 'ROLE_USER'); |
||
| 88 | |||
| 89 | return $rules; |
||
| 90 | })); |
||
| 91 | |||
| 92 | $app['console.commands'] = $app->share( |
||
| 93 | $app->extend('console.commands', function (array $commands) use ($app) { |
||
| 94 | $commands[] = new UserCreateCommand(null, $app['saxulum.userprovider.userclass']); |
||
| 95 | |||
| 96 | return $commands; |
||
| 97 | }) |
||
| 98 | ); |
||
| 99 | |||
| 100 | $app['saxulum.crud.listing.types'] = $app->share(function(){ |
||
| 101 | return array(); |
||
| 102 | }); |
||
| 103 | |||
| 104 | $app['saxulum.crud.listing.factory'] = $app->share(function() use ($app) { |
||
| 105 | return new ListingFactory($app['saxulum.crud.listing.types']); |
||
| 106 | }); |
||
| 107 | |||
| 108 | $this->addControllers($app); |
||
| 109 | $this->addDoctrineOrmMappings($app); |
||
| 110 | $this->addTranslatorRessources($app); |
||
|
|
|||
| 111 | $this->addTwigLoaderFilesystemPath($app); |
||
| 112 | } |
||
| 113 | |||
| 118 |
This method has been deprecated.