Conditions | 5 |
Paths | 12 |
Total Lines | 222 |
Code Lines | 113 |
Lines | 0 |
Ratio | 0 % |
Changes | 6 | ||
Bugs | 3 | 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 namespace crocodicstudio\crudbooster\controllers; |
||
14 | public function cbInit() |
||
15 | { |
||
16 | $this->table = "cms_menus"; |
||
17 | $this->primary_key = "id"; |
||
18 | $this->title_field = "name"; |
||
19 | $this->limit = 20; |
||
20 | $this->orderby = ["id" => "desc"]; |
||
21 | |||
22 | $this->button_table_action = true; |
||
23 | $this->button_action_style = "FALSE"; |
||
24 | $this->button_add = false; |
||
25 | $this->button_delete = true; |
||
26 | $this->button_edit = true; |
||
27 | $this->button_detail = true; |
||
28 | $this->button_show = false; |
||
29 | $this->button_filter = true; |
||
30 | $this->button_export = false; |
||
31 | $this->button_import = false; |
||
32 | |||
33 | $id = CRUDBooster::getCurrentId(); |
||
34 | if (Request::segment(3) == 'edit') { |
||
35 | $id = Request::segment(4); |
||
36 | Session::put('current_row_id', $id); |
||
37 | } |
||
38 | $row = CRUDBooster::first($this->table, $id); |
||
39 | $row = (Request::segment(3) == 'edit') ? $row : null; |
||
40 | |||
41 | $id_module = $id_statistic = 0; |
||
42 | |||
43 | if ($row->type == 'Module') { |
||
44 | $m = CRUDBooster::first('cms_moduls', ['path' => $row->path]); |
||
45 | $id_module = $m->id; |
||
46 | } elseif ($row->type == 'Statistic') { |
||
47 | $row->path = str_replace('statistic_builder/show/', '', $row->path); |
||
48 | $m = CRUDBooster::first('cms_statistics', ['slug' => $row->path]); |
||
49 | $id_statistic = $m->id; |
||
50 | } |
||
51 | |||
52 | $this->script_js = " |
||
53 | $(function() { |
||
54 | var current_id = '$id'; |
||
55 | var current_type = '$row->type'; |
||
56 | var type_menu = $('input[name=type]').val(); |
||
57 | type_menu = (current_type)?current_type:type_menu; |
||
58 | if(type_menu == 'Module') { |
||
59 | $('#form-group-module_slug').show(); |
||
60 | $('#form-group-statistic_slug,#form-group-path').hide(); |
||
61 | $('#module_slug').prop('required',true); |
||
62 | $('#form-group-module_slug label').append('<span class=\"text-danger\" title=\"".trans('crudbooster.this_field_is_required')."\">*</span>'); |
||
63 | }else if(type_menu == 'Statistic') { |
||
64 | $('#form-group-statistic_slug').show(); |
||
65 | $('#module_slug').prop('required',false); |
||
66 | $('#form-group-module_slug,#form-group-path').hide(); |
||
67 | $('#statistic_slug').prop('required',true); |
||
68 | $('#form-group-statistic_slug label').append('<span class=\"text-danger\" title=\"".trans('crudbooster.this_field_is_required')."\">*</span>'); |
||
69 | }else{ |
||
70 | $('#module_slug').prop('required',false); |
||
71 | $('#form-group-module_slug,#form-group-statistic_slug').hide(); |
||
72 | $('#form-group-path').show(); |
||
73 | } |
||
74 | |||
75 | |||
76 | function format(icon) { |
||
77 | var originalOption = icon.element; |
||
78 | var label = $(originalOption).text(); |
||
79 | var val = $(originalOption).val(); |
||
80 | if(!val) return label; |
||
81 | var \$resp = $('<span><i style=\"margin-top:5px\" class=\"pull-right ' + $(originalOption).val() + '\"></i> ' + $(originalOption).data('label') + '</span>'); |
||
82 | return \$resp; |
||
83 | } |
||
84 | $('#list-icon').select2({ |
||
85 | width: \"100%\", |
||
86 | templateResult: format, |
||
87 | templateSelection: format |
||
88 | }); |
||
89 | |||
90 | $('input[name=type]').click(function() { |
||
91 | var default_placeholder_path = 'NameController@methodName'; |
||
92 | var n = $(this).val(); |
||
93 | var isCheck = $(this).prop('checked'); |
||
94 | console.log('Click the module type '+n); |
||
95 | $('#module_slug').prop('required',false); |
||
96 | $('input[name=path]').attr('placeholder',default_placeholder_path); |
||
97 | if(n == 'Module') { |
||
98 | $('#form-group-path').hide(); |
||
99 | $('#form-group-statistic_slug').hide(); |
||
100 | $('#statistic_slug,#path').prop('required',false); |
||
101 | |||
102 | $('#form-group-module_slug').show(); |
||
103 | $('#module_slug').prop('required',true); |
||
104 | $('#form-group-module_slug label .text-danger').remove(); |
||
105 | }else if (n == 'Statistic') { |
||
106 | $('#form-group-path').hide(); |
||
107 | $('#form-group-module_slug').hide(); |
||
108 | $('#module_slug,#path').prop('required',false); |
||
109 | |||
110 | $('#form-group-statistic_slug').show(); |
||
111 | $('#statistic_slug').prop('required',true); |
||
112 | $('#form-group-statistic_slug label .text-danger').remove(); |
||
113 | $('#form-group-statistic_slug label').append('<span class=\"text-danger\" title=\"".trans('crudbooster.this_field_is_required')."\">*</span>'); |
||
114 | }else if (n == 'URL') { |
||
115 | $('input[name=path]').attr('placeholder','Please enter your URL'); |
||
116 | |||
117 | $('#path').prop('required',true); |
||
118 | $('#form-group-path label .text-danger').remove(); |
||
119 | $('#form-group-path label').append('<span class=\"text-danger\" title=\"".trans('crudbooster.this_field_is_required')."\">*</span>'); |
||
120 | |||
121 | $('#form-group-path').show(); |
||
122 | $('#form-group-module_slug,#form-group-statistic_slug').hide(); |
||
123 | }else if (n == 'Route') { |
||
124 | $('input[name=path]').attr('placeholder','Please enter the Route'); |
||
125 | |||
126 | $('#path').prop('required',true); |
||
127 | $('#form-group-path label .text-danger').remove(); |
||
128 | $('#form-group-path label').append('<span class=\"text-danger\" title=\"".trans('crudbooster.this_field_is_required')."\">*</span>'); |
||
129 | |||
130 | $('#form-group-path').show(); |
||
131 | $('#form-group-module_slug,#form-group-statistic_slug').hide(); |
||
132 | }else { |
||
133 | $('#module_slug,#statistic_slug').prop('required',false); |
||
134 | |||
135 | $('#path').prop('required',true); |
||
136 | $('#form-group-path label .text-danger').remove(); |
||
137 | $('#form-group-path label').append('<span class=\"text-danger\" title=\"".trans('crudbooster.this_field_is_required')."\">*</span>'); |
||
138 | |||
139 | $('#form-group-path').show(); |
||
140 | $('#form-group-module_slug,#form-group-statistic_slug').hide(); |
||
141 | } |
||
142 | }) |
||
143 | }) |
||
144 | "; |
||
145 | |||
146 | $this->col = []; |
||
147 | $this->col[] = ["label" => "Name", "name" => "name"]; |
||
148 | $this->col[] = ["label" => "Is Active", "name" => "is_active"]; |
||
149 | $this->col[] = ["label" => "Privileges", "name" => "id_cms_privileges", "join" => "cms_privileges,name"]; |
||
150 | |||
151 | $this->form = []; |
||
152 | $this->form[] = [ |
||
153 | "label" => "Privileges", |
||
154 | "name" => "cms_menus_privileges", |
||
155 | "type" => "select2", |
||
156 | "select2_multiple" => true, |
||
157 | "datatable" => "cms_privileges,name", |
||
158 | "relationship_table" => "cms_menus_privileges", |
||
159 | "required" => true, |
||
160 | ]; |
||
161 | $this->form[] = [ |
||
162 | "label" => "Name", |
||
163 | "name" => "name", |
||
164 | "type" => "text", |
||
165 | "required" => true, |
||
166 | "validation" => "required|min:3|max:255" |
||
167 | ]; |
||
168 | $this->form[] = [ |
||
169 | "label" => "Type", |
||
170 | "name" => "type", |
||
171 | "type" => "radio", |
||
172 | "required" => true, |
||
173 | 'dataenum' => ['Module', 'Statistic', 'URL', 'Controller & Method', 'Route'], |
||
174 | 'value' => 'Module', |
||
175 | ]; |
||
176 | |||
177 | $this->form[] = [ |
||
178 | "label" => "Module", |
||
179 | "name" => "module_slug", |
||
180 | "type" => "select", |
||
181 | "datatable" => "cms_moduls,name", |
||
182 | "datatable_where" => "is_protected = 0", |
||
183 | "value" => $id_module, |
||
184 | ]; |
||
185 | $this->form[] = [ |
||
186 | "label" => "Statistic", |
||
187 | "name" => "statistic_slug", |
||
188 | "type" => "select", |
||
189 | "datatable" => "cms_statistics,name", |
||
190 | "style" => "display:none", |
||
191 | "value" => $id_statistic, |
||
192 | ]; |
||
193 | |||
194 | $this->form[] = [ |
||
195 | "label" => "Value", |
||
196 | "name" => "path", |
||
197 | "type" => "text", |
||
198 | 'help' => 'If you select type controller, you can fill this field with controller name, you may include the method also', |
||
199 | 'placeholder' => 'NameController or NameController@methodName', |
||
200 | "style" => "display:none", |
||
201 | ]; |
||
202 | |||
203 | $fontawesome = Fontawesome::getIcons(); |
||
204 | |||
205 | $custom = view('crudbooster::components.list_icon', compact('fontawesome', 'row'))->render(); |
||
206 | $this->form[] = ['label' => 'Icon', 'name' => 'icon', 'type' => 'custom', 'html' => $custom, 'required' => true]; |
||
207 | $this->form[] = [ |
||
208 | 'label' => 'Color', |
||
209 | 'name' => 'color', |
||
210 | 'type' => 'select2', |
||
211 | 'dataenum' => ['normal', 'red', 'green', 'aqua', 'light-blue', 'red', 'yellow', 'muted'], |
||
212 | 'required' => true, |
||
213 | 'value' => 'normal', |
||
214 | ]; |
||
215 | $this->form[] = [ |
||
216 | "label" => "Active", |
||
217 | "name" => "is_active", |
||
218 | "type" => "radio", |
||
219 | "required" => true, |
||
220 | "validation" => "required|integer", |
||
221 | "dataenum" => ['1|Active', '0|InActive'], |
||
222 | 'value' => '1', |
||
223 | ]; |
||
224 | $this->form[] = [ |
||
225 | "label" => "Dashboard", |
||
226 | "name" => "is_dashboard", |
||
227 | "type" => "radio", |
||
228 | "required" => true, |
||
229 | "validation" => "required|integer", |
||
230 | "dataenum" => ['1|Yes', '0|No'], |
||
231 | 'value' => '0', |
||
232 | ]; |
||
233 | |||
234 | $id_cms_privileges = Request::get('id_cms_privileges'); |
||
235 | $this->form[] = ["label" => "id_cms_privileges", "name" => "id_cms_privileges", "type" => "hidden", "value" => $id_cms_privileges]; |
||
236 | } |
||
353 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths