Code Duplication    Length = 7-9 lines in 4 locations

src/controllers/HubController.php 1 location

@@ 29-37 (lines=9) @@
26
                },
27
            ],
28
            'view' => [
29
                'on beforePerform' => function (Event $event) {
30
                    /** @var \hipanel\actions\SearchAction $action */
31
                    $action = $event->sender;
32
                    $dataProvider = $action->getDataProvider();
33
                    $dataProvider->query->joinWith(['bindings']);
34
                    $dataProvider->query
35
                        ->andWhere(['with_bindings' => 1])
36
                        ->andWhere(['with_servers' => 1]);
37
                },
38
                'class' => ViewAction::class,
39
            ],
40
            'create' => [

src/controllers/ServerController.php 3 locations

@@ 119-127 (lines=9) @@
116
                'success' => Yii::t('hipanel:server', 'Hardware properties was changed'),
117
                'view' => 'hardwareSettings',
118
                'scenario' => 'default',
119
                'on beforeFetch' => function (Event $event) {
120
                    /** @var \hipanel\actions\SearchAction $action */
121
                    $action = $event->sender;
122
                    $dataProvider = $action->getDataProvider();
123
                    $dataProvider->query->joinWith(['hardwareSettings']);
124
                    $dataProvider->query->andWhere(['with_hardwareSettings' => 1])->select(['*']);
125
                },
126
                'on beforeLoad' => function (Event $event) {
127
                    /** @var Action $action */
128
                    $action = $event->sender;
129
130
                    $action->collection->setModel(HardwareSettings::class);
@@ 149-155 (lines=7) @@
146
                'success' => Yii::t('hipanel:server', 'Software properties was changed'),
147
                'view' => 'softwareSettings',
148
                'scenario' => 'default',
149
                'on beforeFetch' => function (Event $event) {
150
                    /** @var \hipanel\actions\SearchAction $action */
151
                    $action = $event->sender;
152
                    $dataProvider = $action->getDataProvider();
153
                    $dataProvider->query->joinWith(['softwareSettings']);
154
                    $dataProvider->query->andWhere(['with_softwareSettings' => 1])->select(['*']);
155
                },
156
                'on beforeLoad' => function (Event $event) {
157
                    /** @var Action $action */
158
                    $action = $event->sender;
@@ 179-186 (lines=8) @@
176
                'success' => Yii::t('hipanel:server', 'Monitoring properties was changed'),
177
                'view' => 'monitoringSettings',
178
                'scenario' => 'default',
179
                'on beforeFetch' => function (Event $event) {
180
                    /** @var \hipanel\actions\SearchAction $action */
181
                    $action = $event->sender;
182
                    $dataProvider = $action->getDataProvider();
183
                    $dataProvider->query->joinWith(['monitoringSettings']);
184
                    $dataProvider->query
185
                        ->andWhere(['with_monitoringSettings' => 1])->select(['*']);
186
                },
187
                'on beforeLoad' => function (Event $event) {
188
                    /** @var Action $action */
189
                    $action = $event->sender;