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

@@ 107-115 (lines=9) @@
104
                'success' => Yii::t('hipanel:server', 'Hardware properties was changed'),
105
                'view' => 'hardwareSettings',
106
                'scenario' => 'default',
107
                'on beforeFetch' => function (Event $event) {
108
                    /** @var \hipanel\actions\SearchAction $action */
109
                    $action = $event->sender;
110
                    $dataProvider = $action->getDataProvider();
111
                    $dataProvider->query->joinWith(['hardwareSettings']);
112
                    $dataProvider->query->andWhere(['with_hardwareSettings' => 1])->select(['*']);
113
                },
114
                'on beforeLoad' => function (Event $event) {
115
                    /** @var Action $action */
116
                    $action = $event->sender;
117
118
                    $action->collection->setModel(HardwareSettings::class);
@@ 137-143 (lines=7) @@
134
                'success' => Yii::t('hipanel:server', 'Software properties was changed'),
135
                'view' => 'softwareSettings',
136
                'scenario' => 'default',
137
                'on beforeFetch' => function (Event $event) {
138
                    /** @var \hipanel\actions\SearchAction $action */
139
                    $action = $event->sender;
140
                    $dataProvider = $action->getDataProvider();
141
                    $dataProvider->query->joinWith(['softwareSettings']);
142
                    $dataProvider->query->andWhere(['with_softwareSettings' => 1])->select(['*']);
143
                },
144
                'on beforeLoad' => function (Event $event) {
145
                    /** @var Action $action */
146
                    $action = $event->sender;
@@ 167-174 (lines=8) @@
164
                'success' => Yii::t('hipanel:server', 'Monitoring properties was changed'),
165
                'view' => 'monitoringSettings',
166
                'scenario' => 'default',
167
                'on beforeFetch' => function (Event $event) {
168
                    /** @var \hipanel\actions\SearchAction $action */
169
                    $action = $event->sender;
170
                    $dataProvider = $action->getDataProvider();
171
                    $dataProvider->query->joinWith(['monitoringSettings']);
172
                    $dataProvider->query
173
                        ->andWhere(['with_monitoringSettings' => 1])->select(['*']);
174
                },
175
                'on beforeLoad' => function (Event $event) {
176
                    /** @var Action $action */
177
                    $action = $event->sender;