@@ -96,18 +96,18 @@ discard block |
||
96 | 96 | public function rules() |
97 | 97 | { |
98 | 98 | return [ |
99 | - ['id', 'integer'], |
|
100 | - ['siteId', 'integer'], |
|
101 | - ['siteId', 'default', 'value' => null], |
|
102 | - ['associatedElementId', 'default', 'value' => 0], |
|
103 | - ['associatedElementId', 'integer'], |
|
104 | - ['enabled', 'boolean'], |
|
105 | - ['redirectSrcMatch', 'default', 'value' => 'pathonly'], |
|
106 | - ['redirectSrcMatch', DbStringValidator::class, 'max' => 32], |
|
107 | - ['redirectSrcMatch', 'string'], |
|
108 | - ['redirectMatchType', 'default', 'value' => 'exactmatch'], |
|
109 | - ['redirectMatchType', DbStringValidator::class, 'max' => 32], |
|
110 | - ['redirectMatchType', 'string'], |
|
99 | + [ 'id', 'integer' ], |
|
100 | + [ 'siteId', 'integer' ], |
|
101 | + [ 'siteId', 'default', 'value' => null ], |
|
102 | + [ 'associatedElementId', 'default', 'value' => 0 ], |
|
103 | + [ 'associatedElementId', 'integer' ], |
|
104 | + [ 'enabled', 'boolean' ], |
|
105 | + [ 'redirectSrcMatch', 'default', 'value' => 'pathonly' ], |
|
106 | + [ 'redirectSrcMatch', DbStringValidator::class, 'max' => 32 ], |
|
107 | + [ 'redirectSrcMatch', 'string' ], |
|
108 | + [ 'redirectMatchType', 'default', 'value' => 'exactmatch' ], |
|
109 | + [ 'redirectMatchType', DbStringValidator::class, 'max' => 32 ], |
|
110 | + [ 'redirectMatchType', 'string' ], |
|
111 | 111 | [ |
112 | 112 | [ |
113 | 113 | 'redirectSrcUrl', |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | 'default', |
118 | 118 | 'value' => '' |
119 | 119 | ], |
120 | - ['redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl'], |
|
120 | + [ 'redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl' ], |
|
121 | 121 | [ |
122 | 122 | [ |
123 | 123 | 'redirectSrcUrl', |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | ], |
145 | 145 | 'string' |
146 | 146 | ], |
147 | - ['redirectHttpCode', 'integer'], |
|
148 | - ['redirectHttpCode', 'default', 'value' => 301], |
|
149 | - ['hitCount', 'default', 'value' => 0], |
|
150 | - ['hitCount', 'integer'], |
|
151 | - ['hitLastTime', 'safe'], |
|
147 | + [ 'redirectHttpCode', 'integer' ], |
|
148 | + [ 'redirectHttpCode', 'default', 'value' => 301 ], |
|
149 | + [ 'hitCount', 'default', 'value' => 0 ], |
|
150 | + [ 'hitCount', 'integer' ], |
|
151 | + [ 'hitLastTime', 'safe' ], |
|
152 | 152 | ]; |
153 | 153 | } |
154 | 154 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | public function actionDashboard(string $range = 'day', int $siteId = 0): Response |
56 | 56 | { |
57 | 57 | PermissionHelper::controllerPermissionCheck('retour:dashboard'); |
58 | - $data = []; |
|
58 | + $data = [ ]; |
|
59 | 59 | $days = 1; |
60 | 60 | switch ($range) { |
61 | 61 | case 'day': |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | 'COUNT(handledByRetour = 1 or null) as handled_cnt', |
82 | 82 | ]) |
83 | 83 | ->where("hitLastTime >= ( CURDATE() - INTERVAL '{$days}' DAY )"); |
84 | - if ((int)$siteId !== 0) { |
|
85 | - $query->andWhere(['siteId' => $siteId]); |
|
84 | + if ((int) $siteId !== 0) { |
|
85 | + $query->andWhere([ 'siteId' => $siteId ]); |
|
86 | 86 | } |
87 | 87 | $query |
88 | 88 | ->orderBy('date_formatted ASC') |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | "COUNT(CASE WHEN \"handledByRetour\" = true THEN 1 END) as handled_cnt", |
100 | 100 | ]) |
101 | 101 | ->where("\"hitLastTime\" >= ( CURRENT_TIMESTAMP - INTERVAL '{$days} days' )"); |
102 | - if ((int)$siteId !== 0) { |
|
103 | - $query->andWhere(['siteId' => $siteId]); |
|
102 | + if ((int) $siteId !== 0) { |
|
103 | + $query->andWhere([ 'siteId' => $siteId ]); |
|
104 | 104 | } |
105 | 105 | $query |
106 | 106 | ->orderBy('date_formatted ASC') |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | $stats = $query->all(); |
109 | 109 | } |
110 | 110 | if ($stats) { |
111 | - $data[] = [ |
|
111 | + $data[ ] = [ |
|
112 | 112 | 'name' => '404 hits', |
113 | - 'data' => array_merge(['0'], ArrayHelper::getColumn($stats, 'cnt')), |
|
114 | - 'labels' => array_merge(['-'], ArrayHelper::getColumn($stats, 'date_formatted')), |
|
113 | + 'data' => array_merge([ '0' ], ArrayHelper::getColumn($stats, 'cnt')), |
|
114 | + 'labels' => array_merge([ '-' ], ArrayHelper::getColumn($stats, 'date_formatted')), |
|
115 | 115 | ]; |
116 | - $data[] = [ |
|
116 | + $data[ ] = [ |
|
117 | 117 | 'name' => 'Handled 404 hits', |
118 | - 'data' => array_merge(['0'], ArrayHelper::getColumn($stats, 'handled_cnt')), |
|
119 | - 'labels' => array_merge(['-'], ArrayHelper::getColumn($stats, 'date_formatted')), |
|
118 | + 'data' => array_merge([ '0' ], ArrayHelper::getColumn($stats, 'handled_cnt')), |
|
119 | + 'labels' => array_merge([ '-' ], ArrayHelper::getColumn($stats, 'date_formatted')), |
|
120 | 120 | ]; |
121 | 121 | } |
122 | 122 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function actionWidget($days = 1): Response |
134 | 134 | { |
135 | - $data = []; |
|
135 | + $data = [ ]; |
|
136 | 136 | // Different dbs do it different ways |
137 | 137 | $stats = null; |
138 | 138 | $handledStats = null; |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | } |
164 | 164 | if ($stats) { |
165 | 165 | $data = [ |
166 | - (int)$stats, |
|
167 | - (int)$handledStats, |
|
166 | + (int) $stats, |
|
167 | + (int) $handledStats, |
|
168 | 168 | ]; |
169 | 169 | } |
170 | 170 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $siteId = 0 |
63 | 63 | ): Response { |
64 | 64 | PermissionHelper::controllerPermissionCheck('retour:dashboard'); |
65 | - $data = []; |
|
65 | + $data = [ ]; |
|
66 | 66 | $sortField = 'hitCount'; |
67 | 67 | $sortType = 'DESC'; |
68 | 68 | // Figure out the sorting type |
@@ -76,42 +76,42 @@ discard block |
||
76 | 76 | // Query the db table |
77 | 77 | $offset = ($page - 1) * $per_page; |
78 | 78 | $query = (new Query()) |
79 | - ->from(['{{%retour_stats}}']) |
|
79 | + ->from([ '{{%retour_stats}}' ]) |
|
80 | 80 | ->offset($offset) |
81 | 81 | ->limit($per_page) |
82 | 82 | ->orderBy("{$sortField} {$sortType}"); |
83 | - if ((int)$siteId !== 0) { |
|
84 | - $query->where(['siteId' => $siteId]); |
|
83 | + if ((int) $siteId !== 0) { |
|
84 | + $query->where([ 'siteId' => $siteId ]); |
|
85 | 85 | } |
86 | 86 | if ($filter !== '') { |
87 | - $query->where(['like', 'redirectSrcUrl', $filter]); |
|
88 | - $query->orWhere(['like', 'referrerUrl', $filter]); |
|
87 | + $query->where([ 'like', 'redirectSrcUrl', $filter ]); |
|
88 | + $query->orWhere([ 'like', 'referrerUrl', $filter ]); |
|
89 | 89 | } |
90 | 90 | $stats = $query->all(); |
91 | 91 | if ($stats) { |
92 | 92 | // Add in the `addLink` field |
93 | 93 | foreach ($stats as &$stat) { |
94 | - $stat['addLink'] = ''; |
|
95 | - if (!$stat['handledByRetour']) { |
|
96 | - $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/')); |
|
97 | - $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [ |
|
94 | + $stat[ 'addLink' ] = ''; |
|
95 | + if (!$stat[ 'handledByRetour' ]) { |
|
96 | + $encodedUrl = urlencode('/' . ltrim($stat[ 'redirectSrcUrl' ], '/')); |
|
97 | + $stat[ 'addLink' ] = UrlHelper::cpUrl('retour/add-redirect', [ |
|
98 | 98 | 'defaultUrl' => $encodedUrl |
99 | 99 | ]); |
100 | 100 | } |
101 | 101 | } |
102 | 102 | // Format the data for the API |
103 | - $data['data'] = $stats; |
|
103 | + $data[ 'data' ] = $stats; |
|
104 | 104 | $query = (new Query()) |
105 | - ->from(['{{%retour_stats}}']); |
|
106 | - if ((int)$siteId !== 0) { |
|
107 | - $query->where(['siteId' => $siteId]); |
|
105 | + ->from([ '{{%retour_stats}}' ]); |
|
106 | + if ((int) $siteId !== 0) { |
|
107 | + $query->where([ 'siteId' => $siteId ]); |
|
108 | 108 | } |
109 | 109 | if ($filter !== '') { |
110 | - $query->where(['like', 'redirectSrcUrl', $filter]); |
|
111 | - $query->orWhere(['like', 'referrerUrl', $filter]); |
|
110 | + $query->where([ 'like', 'redirectSrcUrl', $filter ]); |
|
111 | + $query->orWhere([ 'like', 'referrerUrl', $filter ]); |
|
112 | 112 | } |
113 | 113 | $count = $query->count(); |
114 | - $data['links']['pagination'] = [ |
|
114 | + $data[ 'links' ][ 'pagination' ] = [ |
|
115 | 115 | 'total' => $count, |
116 | 116 | 'per_page' => $per_page, |
117 | 117 | 'current_page' => $page, |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $siteId = 0 |
147 | 147 | ): Response { |
148 | 148 | PermissionHelper::controllerPermissionCheck('retour:redirects'); |
149 | - $data = []; |
|
149 | + $data = [ ]; |
|
150 | 150 | $sortField = 'hitCount'; |
151 | 151 | $sortType = 'DESC'; |
152 | 152 | // Figure out the sorting type |
@@ -160,43 +160,43 @@ discard block |
||
160 | 160 | // Query the db table |
161 | 161 | $offset = ($page - 1) * $per_page; |
162 | 162 | $query = (new Query()) |
163 | - ->from(['{{%retour_static_redirects}}']) |
|
163 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
164 | 164 | ->offset($offset) |
165 | 165 | ->limit($per_page) |
166 | 166 | ->orderBy("{$sortField} {$sortType}"); |
167 | - if ((int)$siteId !== 0) { |
|
168 | - $query->where(['siteId' => $siteId]); |
|
167 | + if ((int) $siteId !== 0) { |
|
168 | + $query->where([ 'siteId' => $siteId ]); |
|
169 | 169 | } |
170 | 170 | if ($filter !== '') { |
171 | - $query->where(['like', 'redirectSrcUrl', $filter]); |
|
172 | - $query->orWhere(['like', 'redirectDestUrl', $filter]); |
|
171 | + $query->where([ 'like', 'redirectSrcUrl', $filter ]); |
|
172 | + $query->orWhere([ 'like', 'redirectDestUrl', $filter ]); |
|
173 | 173 | } |
174 | 174 | $redirects = $query->all(); |
175 | 175 | // Add in the `deleteLink` field and clean up the redirects |
176 | 176 | foreach ($redirects as &$redirect) { |
177 | 177 | // Make sure the destination URL is not a regex |
178 | - if ($redirect['redirectMatchType'] !== 'exactmatch') { |
|
179 | - if (preg_match("/\$\d+/", $redirect['redirectDestUrl'])) { |
|
180 | - $redirect['redirectDestUrl'] = ''; |
|
178 | + if ($redirect[ 'redirectMatchType' ] !== 'exactmatch') { |
|
179 | + if (preg_match("/\$\d+/", $redirect[ 'redirectDestUrl' ])) { |
|
180 | + $redirect[ 'redirectDestUrl' ] = ''; |
|
181 | 181 | } |
182 | 182 | } |
183 | - $redirect['deleteLink'] = UrlHelper::cpUrl('retour/delete-redirect/'.$redirect['id']); |
|
184 | - $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']); |
|
183 | + $redirect[ 'deleteLink' ] = UrlHelper::cpUrl('retour/delete-redirect/' . $redirect[ 'id' ]); |
|
184 | + $redirect[ 'editLink' ] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect[ 'id' ]); |
|
185 | 185 | } |
186 | 186 | // Format the data for the API |
187 | 187 | if ($redirects) { |
188 | - $data['data'] = $redirects; |
|
188 | + $data[ 'data' ] = $redirects; |
|
189 | 189 | $query = (new Query()) |
190 | - ->from(['{{%retour_static_redirects}}']); |
|
191 | - if ((int)$siteId !== 0) { |
|
192 | - $query->where(['siteId' => $siteId]); |
|
190 | + ->from([ '{{%retour_static_redirects}}' ]); |
|
191 | + if ((int) $siteId !== 0) { |
|
192 | + $query->where([ 'siteId' => $siteId ]); |
|
193 | 193 | } |
194 | 194 | if ($filter !== '') { |
195 | - $query->where(['like', 'redirectSrcUrl', $filter]); |
|
196 | - $query->orWhere(['like', 'redirectDestUrl', $filter]); |
|
195 | + $query->where([ 'like', 'redirectSrcUrl', $filter ]); |
|
196 | + $query->orWhere([ 'like', 'redirectDestUrl', $filter ]); |
|
197 | 197 | } |
198 | 198 | $count = $query->count(); |
199 | - $data['links']['pagination'] = [ |
|
199 | + $data[ 'links' ][ 'pagination' ] = [ |
|
200 | 200 | 'total' => $count, |
201 | 201 | 'per_page' => $per_page, |
202 | 202 | 'current_page' => $page, |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public static function setSitesMenuVariables(array &$variables) |
37 | 37 | { |
38 | 38 | // Set defaults based on the section settings |
39 | - $variables['sitesMenu'] = [ |
|
39 | + $variables[ 'sitesMenu' ] = [ |
|
40 | 40 | 0 => Craft::t( |
41 | 41 | 'retour', |
42 | 42 | 'All Sites' |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | /** @var Site $site */ |
50 | 50 | foreach ($sites->getAllGroups() as $group) { |
51 | 51 | $groupSites = $sites->getSitesByGroupId($group->id); |
52 | - $variables['sitesMenu'][$group->name] |
|
53 | - = ['optgroup' => $group->name]; |
|
52 | + $variables[ 'sitesMenu' ][ $group->name ] |
|
53 | + = [ 'optgroup' => $group->name ]; |
|
54 | 54 | foreach ($groupSites as $groupSite) { |
55 | 55 | if (in_array($groupSite->id, $editableSites, false)) { |
56 | - $variables['sitesMenu'][$groupSite->id] = $groupSite->name; |
|
56 | + $variables[ 'sitesMenu' ][ $groupSite->id ] = $groupSite->name; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
@@ -73,53 +73,53 @@ discard block |
||
73 | 73 | $sites = Craft::$app->getSites(); |
74 | 74 | if (Craft::$app->getIsMultiSite()) { |
75 | 75 | // Set defaults based on the section settings |
76 | - $variables['enabledSiteIds'] = []; |
|
77 | - $variables['siteIds'] = []; |
|
76 | + $variables[ 'enabledSiteIds' ] = [ ]; |
|
77 | + $variables[ 'siteIds' ] = [ ]; |
|
78 | 78 | |
79 | 79 | /** @var Site $site */ |
80 | 80 | foreach ($sites->getEditableSiteIds() as $editableSiteId) { |
81 | - $variables['enabledSiteIds'][] = $editableSiteId; |
|
82 | - $variables['siteIds'][] = $editableSiteId; |
|
81 | + $variables[ 'enabledSiteIds' ][ ] = $editableSiteId; |
|
82 | + $variables[ 'siteIds' ][ ] = $editableSiteId; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | // Make sure the $siteId they are trying to edit is in our array of editable sites |
86 | - if (!\in_array($siteId, $variables['enabledSiteIds'], false)) { |
|
87 | - if (!empty($variables['enabledSiteIds'])) { |
|
86 | + if (!\in_array($siteId, $variables[ 'enabledSiteIds' ], false)) { |
|
87 | + if (!empty($variables[ 'enabledSiteIds' ])) { |
|
88 | 88 | if ($siteId !== 0) { |
89 | - $siteId = reset($variables['enabledSiteIds']); |
|
89 | + $siteId = reset($variables[ 'enabledSiteIds' ]); |
|
90 | 90 | } |
91 | 91 | } else { |
92 | - self::requirePermission('editSite:'.$siteId); |
|
92 | + self::requirePermission('editSite:' . $siteId); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | } |
96 | 96 | // Set the currentSiteId and currentSiteHandle |
97 | - $variables['currentSiteId'] = empty($siteId) ? 0 : $siteId; |
|
98 | - $variables['currentSiteHandle'] = empty($siteHandle) |
|
97 | + $variables[ 'currentSiteId' ] = empty($siteId) ? 0 : $siteId; |
|
98 | + $variables[ 'currentSiteHandle' ] = empty($siteHandle) |
|
99 | 99 | ? Craft::$app->getSites()->currentSite->handle |
100 | 100 | : $siteHandle; |
101 | 101 | |
102 | 102 | // Page title |
103 | - $variables['showSites'] = ( |
|
103 | + $variables[ 'showSites' ] = ( |
|
104 | 104 | Craft::$app->getIsMultiSite() && |
105 | - \count($variables['enabledSiteIds']) |
|
105 | + \count($variables[ 'enabledSiteIds' ]) |
|
106 | 106 | ); |
107 | 107 | |
108 | - if ($variables['showSites']) { |
|
109 | - if ($variables['currentSiteId'] === 0) { |
|
110 | - $variables['sitesMenuLabel'] = Craft::t( |
|
108 | + if ($variables[ 'showSites' ]) { |
|
109 | + if ($variables[ 'currentSiteId' ] === 0) { |
|
110 | + $variables[ 'sitesMenuLabel' ] = Craft::t( |
|
111 | 111 | 'retour', |
112 | 112 | 'All Sites' |
113 | 113 | ); |
114 | 114 | } else { |
115 | - $variables['sitesMenuLabel'] = Craft::t( |
|
115 | + $variables[ 'sitesMenuLabel' ] = Craft::t( |
|
116 | 116 | 'site', |
117 | - $sites->getSiteById((int)$variables['currentSiteId'])->name |
|
117 | + $sites->getSiteById((int) $variables[ 'currentSiteId' ])->name |
|
118 | 118 | ); |
119 | 119 | } |
120 | 120 | } else { |
121 | - $variables['currentSiteId'] = 0; |
|
122 | - $variables['sitesMenuLabel'] = ''; |
|
121 | + $variables[ 'currentSiteId' ] = 0; |
|
122 | + $variables[ 'sitesMenuLabel' ] = ''; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | if ($siteHandle !== null) { |
138 | 138 | $site = Craft::$app->getSites()->getSiteByHandle($siteHandle); |
139 | 139 | if (!$site) { |
140 | - throw new NotFoundHttpException('Invalid site handle: '.$siteHandle); |
|
140 | + throw new NotFoundHttpException('Invalid site handle: ' . $siteHandle); |
|
141 | 141 | } |
142 | 142 | $siteId = $site->id; |
143 | 143 | } else { |
@@ -20,7 +20,7 @@ |
||
20 | 20 | // Update retour widget type |
21 | 21 | $this->update('{{%widgets}}', [ |
22 | 22 | 'type' => RetourWidget::class |
23 | - ], ['type' => 'Retour']); |
|
23 | + ], [ 'type' => 'Retour' ]); |
|
24 | 24 | |
25 | 25 | return true; |
26 | 26 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | // Update retour widget type |
21 | 21 | $this->update('{{%widgets}}', [ |
22 | 22 | 'type' => RetourWidget::class |
23 | - ], ['type' => 'Retour']); |
|
23 | + ], [ 'type' => 'Retour' ]); |
|
24 | 24 | |
25 | 25 | return true; |
26 | 26 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | // Protected Properties |
42 | 42 | // ========================================================================= |
43 | 43 | |
44 | - protected $allowAnonymous = []; |
|
44 | + protected $allowAnonymous = [ ]; |
|
45 | 45 | |
46 | 46 | // Public Methods |
47 | 47 | // ========================================================================= |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function actionRedirects(string $siteHandle = null): Response |
59 | 59 | { |
60 | - $variables = []; |
|
60 | + $variables = [ ]; |
|
61 | 61 | PermissionHelper::controllerPermissionCheck('retour:redirects'); |
62 | 62 | // Get the site to edit |
63 | 63 | $siteId = MultiSiteHelper::getSiteIdFromHandle($siteHandle); |
@@ -70,32 +70,32 @@ discard block |
||
70 | 70 | } catch (InvalidConfigException $e) { |
71 | 71 | Craft::error($e->getMessage(), __METHOD__); |
72 | 72 | } |
73 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
73 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
74 | 74 | '@nystudio107/retour/assetbundles/retour/dist', |
75 | 75 | true |
76 | 76 | ); |
77 | 77 | // Enabled sites |
78 | 78 | MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables); |
79 | - $variables['controllerHandle'] = 'redirects'; |
|
79 | + $variables[ 'controllerHandle' ] = 'redirects'; |
|
80 | 80 | |
81 | 81 | // Basic variables |
82 | - $variables['fullPageForm'] = false; |
|
83 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
84 | - $variables['pluginName'] = $pluginName; |
|
85 | - $variables['title'] = $templateTitle; |
|
86 | - $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
87 | - $variables['crumbs'] = [ |
|
82 | + $variables[ 'fullPageForm' ] = false; |
|
83 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
84 | + $variables[ 'pluginName' ] = $pluginName; |
|
85 | + $variables[ 'title' ] = $templateTitle; |
|
86 | + $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
87 | + $variables[ 'crumbs' ] = [ |
|
88 | 88 | [ |
89 | 89 | 'label' => $pluginName, |
90 | 90 | 'url' => UrlHelper::cpUrl('retour'), |
91 | 91 | ], |
92 | 92 | [ |
93 | 93 | 'label' => $templateTitle, |
94 | - 'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri), |
|
94 | + 'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri), |
|
95 | 95 | ], |
96 | 96 | ]; |
97 | - $variables['docTitle'] = "{$pluginName} - {$templateTitle}"; |
|
98 | - $variables['selectedSubnavItem'] = 'redirects'; |
|
97 | + $variables[ 'docTitle' ] = "{$pluginName} - {$templateTitle}"; |
|
98 | + $variables[ 'selectedSubnavItem' ] = 'redirects'; |
|
99 | 99 | |
100 | 100 | // Render the template |
101 | 101 | return $this->renderTemplate('retour/redirects/index', $variables); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | int $siteId = 0, |
120 | 120 | StaticRedirectsModel $redirect = null |
121 | 121 | ): Response { |
122 | - $variables = []; |
|
122 | + $variables = [ ]; |
|
123 | 123 | PermissionHelper::controllerPermissionCheck('retour:redirects'); |
124 | 124 | |
125 | 125 | // Load in the redirect |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | if ($redirect === null) { |
134 | 134 | $redirectConfig = Retour::$plugin->redirects->getRedirectById($redirectId); |
135 | 135 | if ($redirectConfig === null) { |
136 | - $redirectConfig = []; |
|
136 | + $redirectConfig = [ ]; |
|
137 | 137 | Craft::error( |
138 | 138 | Craft::t( |
139 | 139 | 'retour', |
140 | 140 | "Couldn't load redirect id {id}", |
141 | - ['id' => $redirectId] |
|
141 | + [ 'id' => $redirectId ] |
|
142 | 142 | ), |
143 | 143 | __METHOD__ |
144 | 144 | ); |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | if ($redirect->siteId) { |
152 | 152 | $site = $sites->getSiteById($redirect->siteId); |
153 | 153 | if ($site) { |
154 | - MultiSiteHelper::requirePermission('editSite:'.$site->uid); |
|
154 | + MultiSiteHelper::requirePermission('editSite:' . $site->uid); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | if ($siteId) { |
158 | 158 | $site = $sites->getSiteById($siteId); |
159 | 159 | if ($site) { |
160 | - MultiSiteHelper::requirePermission('editSite:'.$site->uid); |
|
160 | + MultiSiteHelper::requirePermission('editSite:' . $site->uid); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | $pluginName = Retour::$settings->pluginName; |
@@ -169,20 +169,20 @@ discard block |
||
169 | 169 | } catch (InvalidConfigException $e) { |
170 | 170 | Craft::error($e->getMessage(), __METHOD__); |
171 | 171 | } |
172 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
172 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
173 | 173 | '@nystudio107/retour/assetbundles/retour/dist', |
174 | 174 | true |
175 | 175 | ); |
176 | 176 | // Sites menu |
177 | 177 | MultiSiteHelper::setSitesMenuVariables($variables); |
178 | - $variables['controllerHandle'] = 'redirects'; |
|
178 | + $variables[ 'controllerHandle' ] = 'redirects'; |
|
179 | 179 | |
180 | 180 | // Basic variables |
181 | - $variables['fullPageForm'] = true; |
|
182 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
183 | - $variables['pluginName'] = $pluginName; |
|
184 | - $variables['title'] = $templateTitle; |
|
185 | - $variables['crumbs'] = [ |
|
181 | + $variables[ 'fullPageForm' ] = true; |
|
182 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
183 | + $variables[ 'pluginName' ] = $pluginName; |
|
184 | + $variables[ 'title' ] = $templateTitle; |
|
185 | + $variables[ 'crumbs' ] = [ |
|
186 | 186 | [ |
187 | 187 | 'label' => $pluginName, |
188 | 188 | 'url' => UrlHelper::cpUrl('retour'), |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | ], |
194 | 194 | [ |
195 | 195 | 'label' => $templateTitle, |
196 | - 'url' => UrlHelper::cpUrl('retour/edit-redirect/'.$redirectId), |
|
196 | + 'url' => UrlHelper::cpUrl('retour/edit-redirect/' . $redirectId), |
|
197 | 197 | ], |
198 | 198 | ]; |
199 | - $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}"; |
|
200 | - $variables['selectedSubnavItem'] = 'redirects'; |
|
201 | - $variables['redirect'] = $redirect; |
|
199 | + $variables[ 'docTitle' ] = "{$pluginName} - Redirects - {$templateTitle}"; |
|
200 | + $variables[ 'selectedSubnavItem' ] = 'redirects'; |
|
201 | + $variables[ 'redirect' ] = $redirect; |
|
202 | 202 | |
203 | 203 | // Render the template |
204 | 204 | return $this->renderTemplate('retour/redirects/_edit', $variables); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | if ($redirectConfig === null) { |
245 | 245 | throw new NotFoundHttpException('Redirect not found'); |
246 | 246 | } |
247 | - $redirectConfig['id'] = (int)$redirectConfig['id']; |
|
247 | + $redirectConfig[ 'id' ] = (int) $redirectConfig[ 'id' ]; |
|
248 | 248 | $redirect = new StaticRedirectsModel($redirectConfig); |
249 | 249 | // Make sure the redirect validates |
250 | 250 | if (!$redirect->validate()) { |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | Retour::$plugin->redirects->saveRedirect($redirectConfig); |
262 | 262 | // Handle the case where the redirect wasn't saved because it'd create a redirect loop |
263 | 263 | $testRedirectConfig = Retour::$plugin->redirects->getRedirectByRedirectSrcUrl( |
264 | - $redirectConfig['redirectSrcUrl'], |
|
265 | - $redirectConfig['siteId'] |
|
264 | + $redirectConfig[ 'redirectSrcUrl' ], |
|
265 | + $redirectConfig[ 'siteId' ] |
|
266 | 266 | ); |
267 | 267 | if ($testRedirectConfig === null) { |
268 | 268 | Craft::$app->getSession()->setError(Craft::t('app', "Couldn't save redirect settings because it'd create a redirect loop.")); |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | public function rules() |
105 | 105 | { |
106 | 106 | return [ |
107 | - ['pluginName', 'string'], |
|
108 | - ['pluginName', 'default', 'value' => 'Retour'], |
|
107 | + [ 'pluginName', 'string' ], |
|
108 | + [ 'pluginName', 'default', 'value' => 'Retour' ], |
|
109 | 109 | [ |
110 | 110 | [ |
111 | 111 | 'createUriChangeRedirects', |
@@ -116,17 +116,17 @@ discard block |
||
116 | 116 | ], |
117 | 117 | 'boolean' |
118 | 118 | ], |
119 | - ['staticRedirectDisplayLimit', 'integer', 'min' => 1], |
|
120 | - ['staticRedirectDisplayLimit', 'default', 'value' => 100], |
|
121 | - ['dynamicRedirectDisplayLimit', 'integer', 'min' => 1], |
|
122 | - ['dynamicRedirectDisplayLimit', 'default', 'value' => 100], |
|
123 | - ['statsStoredLimit', 'integer', 'min' => 1], |
|
124 | - ['statsStoredLimit', 'default', 'value' => 1000], |
|
125 | - ['refreshIntervalSecs', 'integer', 'min' => 0], |
|
126 | - ['refreshIntervalSecs', 'default', 'value' => 3], |
|
127 | - ['statsDisplayLimit', 'integer', 'min' => 1], |
|
128 | - ['statsDisplayLimit', 'default', 'value' => 1000], |
|
129 | - ['excludePatterns', ArrayValidator::class], |
|
119 | + [ 'staticRedirectDisplayLimit', 'integer', 'min' => 1 ], |
|
120 | + [ 'staticRedirectDisplayLimit', 'default', 'value' => 100 ], |
|
121 | + [ 'dynamicRedirectDisplayLimit', 'integer', 'min' => 1 ], |
|
122 | + [ 'dynamicRedirectDisplayLimit', 'default', 'value' => 100 ], |
|
123 | + [ 'statsStoredLimit', 'integer', 'min' => 1 ], |
|
124 | + [ 'statsStoredLimit', 'default', 'value' => 1000 ], |
|
125 | + [ 'refreshIntervalSecs', 'integer', 'min' => 0 ], |
|
126 | + [ 'refreshIntervalSecs', 'default', 'value' => 3 ], |
|
127 | + [ 'statsDisplayLimit', 'integer', 'min' => 1 ], |
|
128 | + [ 'statsDisplayLimit', 'default', 'value' => 1000 ], |
|
129 | + [ 'excludePatterns', ArrayValidator::class ], |
|
130 | 130 | ]; |
131 | 131 | } |
132 | 132 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function behaviors() |
137 | 137 | { |
138 | - $craft31Behaviors = []; |
|
138 | + $craft31Behaviors = [ ]; |
|
139 | 139 | if (Retour::$craft31) { |
140 | 140 | $craft31Behaviors = [ |
141 | 141 | 'parser' => [ |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | // Protected Properties |
41 | 41 | // ========================================================================= |
42 | 42 | |
43 | - protected $allowAnonymous = []; |
|
43 | + protected $allowAnonymous = [ ]; |
|
44 | 44 | |
45 | 45 | // Public Methods |
46 | 46 | // ========================================================================= |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function actionDashboard(string $siteHandle = null, bool $showWelcome = false): Response |
58 | 58 | { |
59 | - $variables = []; |
|
59 | + $variables = [ ]; |
|
60 | 60 | PermissionHelper::controllerPermissionCheck('retour:dashboard'); |
61 | 61 | // Trim the statistics |
62 | 62 | Retour::$plugin->statistics->trimStatistics(); |
@@ -71,34 +71,34 @@ discard block |
||
71 | 71 | } catch (InvalidConfigException $e) { |
72 | 72 | Craft::error($e->getMessage(), __METHOD__); |
73 | 73 | } |
74 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
74 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
75 | 75 | '@nystudio107/retour/assetbundles/retour/dist', |
76 | 76 | true |
77 | 77 | ); |
78 | 78 | // Enabled sites |
79 | 79 | MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables); |
80 | - $variables['controllerHandle'] = 'dashboard'; |
|
80 | + $variables[ 'controllerHandle' ] = 'dashboard'; |
|
81 | 81 | |
82 | 82 | // Basic variables |
83 | - $variables['fullPageForm'] = false; |
|
84 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
85 | - $variables['pluginName'] = $pluginName; |
|
86 | - $variables['title'] = $templateTitle; |
|
87 | - $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
88 | - $variables['crumbs'] = [ |
|
83 | + $variables[ 'fullPageForm' ] = false; |
|
84 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
85 | + $variables[ 'pluginName' ] = $pluginName; |
|
86 | + $variables[ 'title' ] = $templateTitle; |
|
87 | + $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
88 | + $variables[ 'crumbs' ] = [ |
|
89 | 89 | [ |
90 | 90 | 'label' => $pluginName, |
91 | 91 | 'url' => UrlHelper::cpUrl('retour'), |
92 | 92 | ], |
93 | 93 | [ |
94 | 94 | 'label' => $templateTitle, |
95 | - 'url' => UrlHelper::cpUrl('retour/dashboard'.$siteHandleUri), |
|
95 | + 'url' => UrlHelper::cpUrl('retour/dashboard' . $siteHandleUri), |
|
96 | 96 | ], |
97 | 97 | ]; |
98 | - $variables['docTitle'] = "{$pluginName} - {$templateTitle}"; |
|
99 | - $variables['selectedSubnavItem'] = 'dashboard'; |
|
100 | - $variables['showWelcome'] = $showWelcome; |
|
101 | - $variables['settings'] = Retour::$settings; |
|
98 | + $variables[ 'docTitle' ] = "{$pluginName} - {$templateTitle}"; |
|
99 | + $variables[ 'selectedSubnavItem' ] = 'dashboard'; |
|
100 | + $variables[ 'showWelcome' ] = $showWelcome; |
|
101 | + $variables[ 'settings' ] = Retour::$settings; |
|
102 | 102 | |
103 | 103 | // Render the template |
104 | 104 | return $this->renderTemplate('retour/dashboard/index', $variables); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | Craft::t( |
117 | 117 | 'retour', |
118 | 118 | 'Retour statistics cleared: {error}', |
119 | - ['error' => $error] |
|
119 | + [ 'error' => $error ] |
|
120 | 120 | ), |
121 | 121 | __METHOD__ |
122 | 122 | ); |