Conditions | 1 |
Paths | 1 |
Total Lines | 61 |
Code Lines | 38 |
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 |
||
70 | public function getReportField() |
||
71 | { |
||
72 | Requirements::css('bringyourownideas/silverstripe-maintenance: client/dist/styles/bundle.css'); |
||
73 | |||
74 | /** @var GridField $grid */ |
||
75 | $grid = parent::getReportField(); |
||
76 | |||
77 | /** @var GridFieldConfig $config */ |
||
78 | $config = $grid->getConfig(); |
||
79 | |||
80 | $grid->addExtraClass('package-summary'); |
||
81 | |||
82 | /** @var GridFieldExportButton $exportButton */ |
||
83 | $exportButton = $config->getComponentByType(GridFieldExportButton::class); |
||
84 | $exportButton->setExportColumns(Package::create()->summaryFields()); |
||
85 | |||
86 | $versionHtml = ArrayData::create([ |
||
87 | 'Title' => _t(__CLASS__ . '.VERSION', 'Version'), |
||
88 | 'Version' => $this->resolveCmsVersion(), |
||
89 | 'LastUpdated' => $this->getLastUpdated(), |
||
90 | ])->renderWith('SiteSummary_VersionHeader'); |
||
91 | |||
92 | /** @var GridFieldDropdownFilter $dropdownFilter */ |
||
93 | $dropdownFilter = Injector::inst()->create( |
||
94 | GridFieldDropdownFilter::class, |
||
95 | 'addonFilter', |
||
96 | 'buttons-before-right', |
||
97 | _t(__CLASS__ . '.ShowAllModules', 'Show all modules') |
||
98 | ); |
||
99 | |||
100 | $dropdownFilter->addFilterOption( |
||
101 | 'supported', |
||
102 | _t(__CLASS__ . '.FilterSupported', 'Supported modules'), |
||
103 | ['Supported' => true] |
||
104 | ); |
||
105 | $dropdownFilter->addFilterOption( |
||
106 | 'unsupported', |
||
107 | _t(__CLASS__ . '.FilterUnsupported', 'Unsupported modules'), |
||
108 | ['Supported' => false] |
||
109 | ); |
||
110 | |||
111 | $this->extend('updateDropdownFilterOptions', $dropdownFilter); |
||
112 | |||
113 | $config->addComponents( |
||
114 | Injector::inst()->create(GridFieldRefreshButton::class, 'buttons-before-left'), |
||
115 | Injector::inst()->create( |
||
116 | GridFieldLinkButton::class, |
||
117 | 'https://addons.silverstripe.org', |
||
118 | _t(__CLASS__ . '.LINK_TO_ADDONS', 'Explore Addons'), |
||
119 | 'buttons-before-left' |
||
120 | ), |
||
121 | $dropdownFilter, |
||
122 | Injector::inst()->create(GridFieldHtmlFragment::class, 'header', $versionHtml) |
||
123 | ); |
||
124 | |||
125 | // Re-order the paginator to ensure it counts correctly. |
||
126 | $paginator = $config->getComponentByType(GridFieldPaginator::class); |
||
127 | $config->removeComponent($paginator); |
||
128 | $config->addComponent($paginator); |
||
129 | |||
130 | return $grid; |
||
131 | } |
||
178 |