Conditions | 2 |
Paths | 2 |
Total Lines | 62 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
34 | public function getConfigTreeBuilder() |
||
35 | { |
||
36 | $treeBuilder = new TreeBuilder('sonata_doctrine_phpcr_admin'); |
||
37 | |||
38 | // Keep compatibility with symfony/config < 4.2 |
||
39 | if (!method_exists($treeBuilder, 'getRootNode')) { |
||
40 | $rootNode = $treeBuilder->root('sonata_doctrine_phpcr_admin'); |
||
|
|||
41 | } else { |
||
42 | $rootNode = $treeBuilder->getRootNode(); |
||
43 | } |
||
44 | |||
45 | $rootNode |
||
46 | ->fixXmlConfig('template') |
||
47 | ->children() |
||
48 | ->arrayNode('templates') |
||
49 | ->children() |
||
50 | ->arrayNode('form') |
||
51 | ->prototype('scalar')->end() |
||
52 | ->defaultValue(['@SonataDoctrinePHPCRAdmin/Form/form_admin_fields.html.twig']) |
||
53 | ->end() |
||
54 | ->arrayNode('filter') |
||
55 | ->prototype('scalar')->end() |
||
56 | ->defaultValue(['@SonataDoctrinePHPCRAdmin/Form/filter_admin_fields.html.twig']) |
||
57 | ->end() |
||
58 | ->arrayNode('types') |
||
59 | ->children() |
||
60 | ->arrayNode('list') |
||
61 | ->useAttributeAsKey('name') |
||
62 | ->prototype('scalar')->end() |
||
63 | ->end() |
||
64 | ->arrayNode('show') |
||
65 | ->useAttributeAsKey('name') |
||
66 | ->prototype('scalar')->end() |
||
67 | ->end() |
||
68 | ->end() |
||
69 | ->end() |
||
70 | ->scalarNode('pager_results')->defaultValue('@SonataDoctrinePHPCRAdmin/Pager/simple_pager_results.html.twig')->cannotBeEmpty()->end() |
||
71 | ->end() |
||
72 | ->end() |
||
73 | ->arrayNode('document_tree') |
||
74 | ->addDefaultsIfNotSet() |
||
75 | ->canBeEnabled() |
||
76 | ->children() |
||
77 | ->scalarNode('repository_name') |
||
78 | ->defaultNull() |
||
79 | ->info('The repository name the resource API connects to.') |
||
80 | ->end() |
||
81 | ->arrayNode('routing_defaults') |
||
82 | ->prototype('scalar')->end() |
||
83 | ->info('Routing defaults passed to the resources API call.') |
||
84 | ->end() |
||
85 | ->scalarNode('sortable_by') |
||
86 | ->defaultValue('position') |
||
87 | ->info('Defines by which property to sort sibling documents.') |
||
88 | ->end() |
||
89 | ->end() |
||
90 | ->end() |
||
91 | ->end() |
||
92 | ; |
||
93 | |||
94 | return $treeBuilder; |
||
95 | } |
||
96 | } |
||
97 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.