| Conditions | 1 |
| Paths | 1 |
| Total Lines | 77 |
| Code Lines | 70 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 1 | Features | 2 |
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 |
||
| 32 | public function getConfigTreeBuilder() |
||
| 33 | { |
||
| 34 | $treeBuilder = new TreeBuilder(); |
||
| 35 | $rootNode = $treeBuilder->root('sonata_doctrine_phpcr_admin', 'array'); |
||
| 36 | |||
| 37 | $rootNode |
||
| 38 | ->fixXmlConfig('document_tree_default') |
||
| 39 | ->fixXmlConfig('template') |
||
| 40 | ->children() |
||
| 41 | ->arrayNode('templates') |
||
| 42 | ->addDefaultsIfNotSet() |
||
| 43 | ->children() |
||
| 44 | ->arrayNode('form') |
||
| 45 | ->prototype('scalar')->end() |
||
| 46 | ->defaultValue(array('SonataDoctrinePHPCRAdminBundle:Form:form_admin_fields.html.twig')) |
||
| 47 | ->end() |
||
| 48 | ->arrayNode('filter') |
||
| 49 | ->prototype('scalar')->end() |
||
| 50 | ->defaultValue(array('SonataDoctrinePHPCRAdminBundle:Form:filter_admin_fields.html.twig')) |
||
| 51 | ->end() |
||
| 52 | ->arrayNode('types') |
||
| 53 | ->children() |
||
| 54 | ->arrayNode('list') |
||
| 55 | ->useAttributeAsKey('name') |
||
| 56 | ->prototype('scalar')->end() |
||
| 57 | ->end() |
||
| 58 | ->arrayNode('show') |
||
| 59 | ->useAttributeAsKey('name') |
||
| 60 | ->prototype('scalar')->end() |
||
| 61 | ->end() |
||
| 62 | ->end() |
||
| 63 | ->end() |
||
| 64 | ->scalarNode('pager_results')->defaultValue('SonataDoctrinePHPCRAdminBundle:Pager:simple_pager_results.html.twig')->cannotBeEmpty()->end() |
||
| 65 | ->end() |
||
| 66 | ->end() |
||
| 67 | ->arrayNode('document_tree') |
||
| 68 | ->useAttributeAsKey('class') |
||
| 69 | ->prototype('array') |
||
| 70 | ->fixXmlConfig('valid_child', 'valid_children') |
||
| 71 | ->children() |
||
| 72 | ->arrayNode('valid_children') |
||
| 73 | ->prototype('scalar')->end() |
||
| 74 | ->info('class names of valid children, manage tree operations for them and hide other children') |
||
| 75 | ->end() |
||
| 76 | ->scalarNode('image') |
||
| 77 | ->defaultValue('') |
||
| 78 | ->end() |
||
| 79 | ->end() |
||
| 80 | ->end() |
||
| 81 | ->end() |
||
| 82 | |||
| 83 | ->arrayNode('document_tree_defaults') |
||
| 84 | ->prototype('scalar')->end() |
||
| 85 | ->end() |
||
| 86 | |||
| 87 | ->arrayNode('document_tree_options') |
||
| 88 | ->addDefaultsIfNotSet() |
||
| 89 | ->children() |
||
| 90 | ->integerNode('depth') |
||
| 91 | ->defaultValue(1) |
||
| 92 | ->info('Depth to which to fetch tree children when rendering the initial tree') |
||
| 93 | ->end() |
||
| 94 | ->scalarNode('precise_children') |
||
| 95 | ->defaultTrue() |
||
| 96 | ->info('Exact check if document has children. For large trees, set to false for better performance, but user might needs to click on expand to see there are no children.') |
||
| 97 | ->end() |
||
| 98 | ->booleanNode('confirm_move') |
||
| 99 | ->defaultTrue() |
||
| 100 | ->info('Whether moving a node in the tree asks for confirmation.') |
||
| 101 | ->end() |
||
| 102 | ->end() |
||
| 103 | ->end() |
||
| 104 | ->end() |
||
| 105 | ; |
||
| 106 | |||
| 107 | return $treeBuilder; |
||
| 108 | } |
||
| 109 | } |
||
| 111 |