Code Duplication    Length = 14-16 lines in 2 locations

src/controllers/ServerController.php 2 locations

@@ 72-85 (lines=14) @@
69
            'index' => [
70
                'class' => IndexAction::class,
71
                'findOptions' => ['with_requests' => true, 'with_discounts' => true],
72
                'on beforePerform' => function (Event $event) {
73
                    /** @var \hipanel\actions\SearchAction $action */
74
                    $action = $event->sender;
75
                    $dataProvider = $action->getDataProvider();
76
                    $dataProvider->query->joinWith('ips');
77
78
                    $dataProvider->query
79
                        ->andWhere(['with_ips' => 1])
80
                        ->andWhere(['with_tariffs' => 1])
81
                        ->andWhere(['with_switches' => 1])
82
                        ->andWhere(['with_requests' => 1])
83
                        ->andWhere(['with_discounts' => 1])
84
                        ->select(['*']);
85
                },
86
                'filterStorageMap' => [
87
                    'name_like' => 'server.server.name',
88
                    'ips' => 'hosting.ip.ip_in',
@@ 99-114 (lines=16) @@
96
            ],
97
            'view' => [
98
                'class' => ViewAction::class,
99
                'on beforePerform' => function (Event $event) {
100
                    /** @var \hipanel\actions\SearchAction $action */
101
                    $action = $event->sender;
102
                    $dataProvider = $action->getDataProvider();
103
                    $dataProvider->query->joinWith('uses');
104
                    $dataProvider->query->joinWith('ips');
105
106
                    // TODO: ipModule is not wise yet. Redo
107
                    $dataProvider->query
108
                        ->andWhere(['with_requests' => 1])
109
                        ->andWhere(['show_deleted' => 1])
110
                        ->andWhere(['with_discounts' => 1])
111
                        ->andWhere(['with_uses' => 1])
112
                        ->andWhere(['with_ips' => 1])
113
                        ->select(['*']);
114
                },
115
                'data' => function ($action) {
116
                    /**
117
                     * @var Action $action