Code Duplication    Length = 11-14 lines in 3 locations

src/controllers/HdomainController.php 1 location

@@ 141-154 (lines=14) @@
138
                        'class' => RedirectAction::class,
139
                    ],
140
                ],
141
                'on beforeSave' => function (Event $event) {
142
                    /** @var \hipanel\actions\Action $action */
143
                    $action = $event->sender;
144
                    $type = Yii::$app->request->post('type');
145
                    $comment = Yii::$app->request->post('comment');
146
                    if (!empty($type)) {
147
                        foreach ($action->collection->models as $model) {
148
                            $model->setAttributes([
149
                                'type' => $type,
150
                                'comment' => $comment,
151
                            ]);
152
                        }
153
                    }
154
                },
155
            ],
156
            'bulk-enable-block-modal' => [
157
                'class' => PrepareBulkAction::class,

src/controllers/AccountController.php 2 locations

@@ 170-183 (lines=14) @@
167
                        'class' => RedirectAction::class,
168
                    ],
169
                ],
170
                'on beforeSave' => function (Event $event) {
171
                    /** @var \hipanel\actions\Action $action */
172
                    $action = $event->sender;
173
                    $type = Yii::$app->request->post('type');
174
                    $comment = Yii::$app->request->post('comment');
175
                    if (!empty($type)) {
176
                        foreach ($action->collection->models as $model) {
177
                            $model->setAttributes([
178
                                'type' => $type,
179
                                'comment' => $comment,
180
                            ]);
181
                        }
182
                    }
183
                },
184
            ],
185
            'bulk-enable-block-modal' => [
186
                'class' => PrepareBulkAction::class,
@@ 204-214 (lines=11) @@
201
                        'class' => RedirectAction::class,
202
                    ],
203
                ],
204
                'on beforeSave' => function (Event $event) {
205
                    /** @var \hipanel\actions\Action $action */
206
                    $action = $event->sender;
207
                    $type = Yii::$app->request->post('type');
208
                    $comment = Yii::$app->request->post('comment');
209
                    if (!empty($type)) {
210
                        foreach ($action->collection->models as $model) {
211
                            $model->setAttribute('comment', $comment);
212
                        }
213
                    }
214
                },
215
            ],
216
            'bulk-disable-block-modal' => [
217
                'class' => PrepareBulkAction::class,