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

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