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

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