@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | // Query the db table |
| 62 | 62 | $stats = (new Query()) |
| 63 | - ->from(['{{%retour_stats}}']) |
|
| 63 | + ->from([ '{{%retour_stats}}' ]) |
|
| 64 | 64 | ->orderBy('hitCount DESC') |
| 65 | 65 | ->limit(Retour::$settings->statsDisplayLimit) |
| 66 | 66 | ->all(); |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | public function getRecentStatistics($days = 1, $handled = false): array |
| 80 | 80 | { |
| 81 | 81 | // Ensure is an int |
| 82 | - $handledInt = (int)$handled; |
|
| 83 | - $stats = []; |
|
| 82 | + $handledInt = (int) $handled; |
|
| 83 | + $stats = [ ]; |
|
| 84 | 84 | $db = Craft::$app->getDb(); |
| 85 | 85 | if ($db->getIsMysql()) { |
| 86 | 86 | // Query the db table |
| 87 | 87 | $stats = (new Query()) |
| 88 | - ->from(['{{%retour_stats}}']) |
|
| 88 | + ->from([ '{{%retour_stats}}' ]) |
|
| 89 | 89 | ->where("hitLastTime >= ( CURDATE() - INTERVAL '{$days}' DAY )") |
| 90 | 90 | ->andWhere("handledByRetour = {$handledInt}") |
| 91 | 91 | ->orderBy('hitLastTime DESC') |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | if ($db->getIsPgsql()) { |
| 95 | 95 | // Query the db table |
| 96 | 96 | $stats = (new Query()) |
| 97 | - ->from(['{{%retour_stats}}']) |
|
| 97 | + ->from([ '{{%retour_stats}}' ]) |
|
| 98 | 98 | ->where("\"hitLastTime\" >= ( CURRENT_TIMESTAMP - INTERVAL '{$days} days' )") |
| 99 | - ->andWhere(['handledByRetour' => $handledInt]) |
|
| 99 | + ->andWhere([ 'handledByRetour' => $handledInt ]) |
|
| 100 | 100 | ->orderBy('hitLastTime DESC') |
| 101 | 101 | ->all(); |
| 102 | 102 | } |
@@ -163,16 +163,16 @@ discard block |
||
| 163 | 163 | $stats->validate(); |
| 164 | 164 | // Find any existing retour_stats record |
| 165 | 165 | $statsConfig = (new Query()) |
| 166 | - ->from(['{{%retour_stats}}']) |
|
| 167 | - ->where(['redirectSrcUrl' => $stats->redirectSrcUrl]) |
|
| 166 | + ->from([ '{{%retour_stats}}' ]) |
|
| 167 | + ->where([ 'redirectSrcUrl' => $stats->redirectSrcUrl ]) |
|
| 168 | 168 | ->one(); |
| 169 | 169 | // If no record is found, initialize some values |
| 170 | 170 | if ($statsConfig === null) { |
| 171 | 171 | $stats->id = 0; |
| 172 | 172 | $stats->hitCount = 0; |
| 173 | 173 | } else { |
| 174 | - $stats->id = $statsConfig['id']; |
|
| 175 | - $stats->hitCount = $statsConfig['hitCount']; |
|
| 174 | + $stats->id = $statsConfig[ 'id' ]; |
|
| 175 | + $stats->hitCount = $statsConfig[ 'hitCount' ]; |
|
| 176 | 176 | } |
| 177 | 177 | // Merge in the updated info |
| 178 | 178 | $stats->siteId = $siteId; |
@@ -181,9 +181,9 @@ discard block |
||
| 181 | 181 | $stats->userAgent = $userAgent; |
| 182 | 182 | $stats->exceptionMessage = $exceptionMessage; |
| 183 | 183 | $stats->exceptionFilePath = $exceptionFilePath; |
| 184 | - $stats->exceptionFileLine = (int)$exceptionFileLine; |
|
| 184 | + $stats->exceptionFileLine = (int) $exceptionFileLine; |
|
| 185 | 185 | $stats->hitLastTime = Db::prepareDateForDb(new \DateTime()); |
| 186 | - $stats->handledByRetour = (int)$handled; |
|
| 186 | + $stats->handledByRetour = (int) $handled; |
|
| 187 | 187 | $stats->hitCount++; |
| 188 | 188 | $statsConfig = $stats->getAttributes(); |
| 189 | 189 | // Record the updated statistics |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | Craft::t( |
| 254 | 254 | 'retour', |
| 255 | 255 | 'Trimmed {rows} from retour_stats table', |
| 256 | - ['rows' => $affectedRows] |
|
| 256 | + [ 'rows' => $affectedRows ] |
|
| 257 | 257 | ), |
| 258 | 258 | __METHOD__ |
| 259 | 259 | ); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | Craft::t( |
| 275 | 275 | 'retour', |
| 276 | 276 | 'Error validating statistics {id}: {errors}', |
| 277 | - ['id' => $stats->id, 'errors' => print_r($stats->getErrors(), true)] |
|
| 277 | + [ 'id' => $stats->id, 'errors' => print_r($stats->getErrors(), true) ] |
|
| 278 | 278 | ), |
| 279 | 279 | __METHOD__ |
| 280 | 280 | ); |
@@ -284,14 +284,14 @@ discard block |
||
| 284 | 284 | // Get the validated model attributes and save them to the db |
| 285 | 285 | $statsConfig = $stats->getAttributes(); |
| 286 | 286 | $db = Craft::$app->getDb(); |
| 287 | - if ($statsConfig['id'] !== 0) { |
|
| 287 | + if ($statsConfig[ 'id' ] !== 0) { |
|
| 288 | 288 | // Update the existing record |
| 289 | 289 | try { |
| 290 | 290 | $result = $db->createCommand()->update( |
| 291 | 291 | '{{%retour_stats}}', |
| 292 | 292 | $statsConfig, |
| 293 | 293 | [ |
| 294 | - 'id' => $statsConfig['id'], |
|
| 294 | + 'id' => $statsConfig[ 'id' ], |
|
| 295 | 295 | ] |
| 296 | 296 | )->execute(); |
| 297 | 297 | } catch (Exception $e) { |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | // Craft::error($e->getMessage(), __METHOD__); |
| 301 | 301 | } |
| 302 | 302 | } else { |
| 303 | - unset($statsConfig['id']); |
|
| 303 | + unset($statsConfig[ 'id' ]); |
|
| 304 | 304 | // Create a new record |
| 305 | 305 | try { |
| 306 | 306 | $db->createCommand()->insert( |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | $now = round(microtime(true) * 1000); |
| 328 | 328 | $cache = Craft::$app->getCache(); |
| 329 | 329 | $then = $cache->get(self::LAST_STATISTICS_TRIM_CACHE_KEY); |
| 330 | - if (($then !== false) && ($now - (int)$then < Retour::$settings->statisticsRateLimitMs)) { |
|
| 330 | + if (($then !== false) && ($now - (int) $then < Retour::$settings->statisticsRateLimitMs)) { |
|
| 331 | 331 | $limited = true; |
| 332 | 332 | } |
| 333 | 333 | $cache->set(self::LAST_STATISTICS_TRIM_CACHE_KEY, $now, 0); |
@@ -62,36 +62,36 @@ discard block |
||
| 62 | 62 | // Boolean field |
| 63 | 63 | $retourField |
| 64 | 64 | ->addBooleanField($field) |
| 65 | - ->resolve(function ($redirect) use ($field) { |
|
| 66 | - $result = $redirect[$field] ?? null; |
|
| 67 | - return $result === null ? $result : (bool)$result; |
|
| 65 | + ->resolve(function($redirect) use ($field) { |
|
| 66 | + $result = $redirect[ $field ] ?? null; |
|
| 67 | + return $result === null ? $result : (bool) $result; |
|
| 68 | 68 | }); |
| 69 | 69 | } elseif (in_array($field, self::INT_FIELDS, true)) { |
| 70 | 70 | // Integer field |
| 71 | 71 | $retourField |
| 72 | 72 | ->addIntField($field) |
| 73 | - ->resolve(function ($redirect) use ($field) { |
|
| 74 | - $result = $redirect[$field] ?? null; |
|
| 75 | - return $result === null ? $result : (int)$result; |
|
| 73 | + ->resolve(function($redirect) use ($field) { |
|
| 74 | + $result = $redirect[ $field ] ?? null; |
|
| 75 | + return $result === null ? $result : (int) $result; |
|
| 76 | 76 | }); |
| 77 | 77 | } else { |
| 78 | 78 | // String field |
| 79 | 79 | $retourField |
| 80 | 80 | ->addStringField($field) |
| 81 | - ->resolve(function ($redirect) use ($field) { |
|
| 82 | - $result = $redirect[$field] ?? null; |
|
| 83 | - return $result === null ? $result : (string)$result; |
|
| 81 | + ->resolve(function($redirect) use ($field) { |
|
| 82 | + $result = $redirect[ $field ] ?? null; |
|
| 83 | + return $result === null ? $result : (string) $result; |
|
| 84 | 84 | }); |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | // Add the root |
| 88 | 88 | $event->schema->addField('retour') |
| 89 | - ->arguments(function (FieldBuilder $field) { |
|
| 89 | + ->arguments(function(FieldBuilder $field) { |
|
| 90 | 90 | $field->addStringArgument('uri'); |
| 91 | 91 | $field->addIntArgument('siteId'); |
| 92 | 92 | }) |
| 93 | 93 | ->type($retourField) |
| 94 | - ->resolve(function ($root, $args, $context, $info) { |
|
| 94 | + ->resolve(function($root, $args, $context, $info) { |
|
| 95 | 95 | // If our root is an Element, extract the URI and siteId from it |
| 96 | 96 | if ($root instanceof Element) { |
| 97 | 97 | /** Element $root */ |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | $siteId = $root->siteId; |
| 100 | 100 | } else { |
| 101 | 101 | // Otherwise use the passed in arguments, or defaults |
| 102 | - $uri = $args['uri'] ?? '/'; |
|
| 103 | - $siteId = $args['siteId'] ?? null; |
|
| 102 | + $uri = $args[ 'uri' ] ?? '/'; |
|
| 103 | + $siteId = $args[ 'siteId' ] ?? null; |
|
| 104 | 104 | } |
| 105 | 105 | $uri = trim($uri === '/' ? '__home__' : $uri); |
| 106 | 106 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | // Protected Properties |
| 74 | 74 | // ========================================================================= |
| 75 | 75 | |
| 76 | - protected $allowAnonymous = []; |
|
| 76 | + protected $allowAnonymous = [ ]; |
|
| 77 | 77 | |
| 78 | 78 | // Public Methods |
| 79 | 79 | // ========================================================================= |
@@ -115,20 +115,20 @@ discard block |
||
| 115 | 115 | if ($headers !== null) { |
| 116 | 116 | $csv->setOffset(1); |
| 117 | 117 | $columns = ArrayHelper::filterEmptyStringsFromArray($columns); |
| 118 | - $csv->each(function ($row) use ($headers, $columns) { |
|
| 118 | + $csv->each(function($row) use ($headers, $columns) { |
|
| 119 | 119 | $redirectConfig = [ |
| 120 | 120 | 'id' => 0, |
| 121 | 121 | ]; |
| 122 | 122 | $index = 0; |
| 123 | 123 | foreach (self::IMPORT_REDIRECTS_CSV_FIELDS as $importField) { |
| 124 | - if (isset($columns[$index], $headers[$columns[$index]])) { |
|
| 125 | - $redirectConfig[$importField] = empty($row[$headers[$columns[$index]]]) |
|
| 124 | + if (isset($columns[ $index ], $headers[ $columns[ $index ] ])) { |
|
| 125 | + $redirectConfig[ $importField ] = empty($row[ $headers[ $columns[ $index ] ] ]) |
|
| 126 | 126 | ? null |
| 127 | - : $row[$headers[$columns[$index]]]; |
|
| 127 | + : $row[ $headers[ $columns[ $index ] ] ]; |
|
| 128 | 128 | } |
| 129 | 129 | $index++; |
| 130 | 130 | } |
| 131 | - Craft::debug('Importing row: '.print_r($redirectConfig, true), __METHOD__); |
|
| 131 | + Craft::debug('Importing row: ' . print_r($redirectConfig, true), __METHOD__); |
|
| 132 | 132 | Retour::$plugin->redirects->saveRedirect($redirectConfig); |
| 133 | 133 | |
| 134 | 134 | return true; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function actionImportCsv(string $siteHandle = null): Response |
| 154 | 154 | { |
| 155 | - $variables = []; |
|
| 155 | + $variables = [ ]; |
|
| 156 | 156 | PermissionHelper::controllerPermissionCheck('retour:redirects'); |
| 157 | 157 | // If your CSV document was created or is read on a Macintosh computer, |
| 158 | 158 | // add the following lines before using the library to help PHP detect line ending in Mac OS X |
@@ -170,38 +170,38 @@ discard block |
||
| 170 | 170 | } catch (InvalidConfigException $e) { |
| 171 | 171 | Craft::error($e->getMessage(), __METHOD__); |
| 172 | 172 | } |
| 173 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 173 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 174 | 174 | '@nystudio107/retour/assetbundles/retour/dist', |
| 175 | 175 | true |
| 176 | 176 | ); |
| 177 | 177 | // Enabled sites |
| 178 | 178 | MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 179 | - $variables['controllerHandle'] = 'file'; |
|
| 179 | + $variables[ 'controllerHandle' ] = 'file'; |
|
| 180 | 180 | |
| 181 | 181 | // Basic variables |
| 182 | - $variables['fullPageForm'] = true; |
|
| 183 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 184 | - $variables['pluginName'] = $pluginName; |
|
| 185 | - $variables['title'] = $templateTitle; |
|
| 186 | - $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
| 187 | - $variables['crumbs'] = [ |
|
| 182 | + $variables[ 'fullPageForm' ] = true; |
|
| 183 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 184 | + $variables[ 'pluginName' ] = $pluginName; |
|
| 185 | + $variables[ 'title' ] = $templateTitle; |
|
| 186 | + $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
| 187 | + $variables[ 'crumbs' ] = [ |
|
| 188 | 188 | [ |
| 189 | 189 | 'label' => $pluginName, |
| 190 | 190 | 'url' => UrlHelper::cpUrl('retour'), |
| 191 | 191 | ], |
| 192 | 192 | [ |
| 193 | 193 | 'label' => 'Redirects', |
| 194 | - 'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri), |
|
| 194 | + 'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri), |
|
| 195 | 195 | ], |
| 196 | 196 | ]; |
| 197 | - $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}"; |
|
| 198 | - $variables['selectedSubnavItem'] = 'redirects'; |
|
| 197 | + $variables[ 'docTitle' ] = "{$pluginName} - Redirects - {$templateTitle}"; |
|
| 198 | + $variables[ 'selectedSubnavItem' ] = 'redirects'; |
|
| 199 | 199 | |
| 200 | 200 | // The CSV file |
| 201 | 201 | $file = UploadedFile::getInstanceByName('file'); |
| 202 | 202 | if ($file !== null) { |
| 203 | 203 | $filename = uniqid($file->name, true); |
| 204 | - $filePath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$filename; |
|
| 204 | + $filePath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $filename; |
|
| 205 | 205 | $file->saveAs($filePath, false); |
| 206 | 206 | // Also save the file to the cache as a backup way to access it |
| 207 | 207 | $cache = Craft::$app->getCache(); |
@@ -217,8 +217,8 @@ discard block |
||
| 217 | 217 | $csv = Reader::createFromPath($file->tempName); |
| 218 | 218 | $headers = $csv->fetchOne(0); |
| 219 | 219 | Craft::info(print_r($headers, true), __METHOD__); |
| 220 | - $variables['headers'] = $headers; |
|
| 221 | - $variables['filename'] = $filePath; |
|
| 220 | + $variables[ 'headers' ] = $headers; |
|
| 221 | + $variables[ 'filename' ] = $filePath; |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // Render the template |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | } |
| 265 | 265 | // Query the db table |
| 266 | 266 | $data = (new Query()) |
| 267 | - ->from([$table]) |
|
| 267 | + ->from([ $table ]) |
|
| 268 | 268 | ->select(array_keys($columns)) |
| 269 | 269 | ->orderBy('hitCount DESC') |
| 270 | 270 | ->all(); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $csv = Writer::createFromFileObject(new \SplTempFileObject()); |
| 273 | 273 | $csv->insertOne(array_values($columns)); |
| 274 | 274 | $csv->insertAll($data); |
| 275 | - $csv->output($filename.'.csv'); |
|
| 275 | + $csv->output($filename . '.csv'); |
|
| 276 | 276 | exit(0); |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | Craft::t( |
| 169 | 169 | 'retour', |
| 170 | 170 | '404 full URL: {fullUrl}, 404 path only: {pathOnly}', |
| 171 | - ['fullUrl' => $fullUrl, 'pathOnly' => $pathOnly] |
|
| 171 | + [ 'fullUrl' => $fullUrl, 'pathOnly' => $pathOnly ] |
|
| 172 | 172 | ), |
| 173 | 173 | __METHOD__ |
| 174 | 174 | ); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $response = Craft::$app->getResponse(); |
| 203 | 203 | if ($redirect !== null) { |
| 204 | 204 | // Figure out what type of source matching was done |
| 205 | - $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly'; |
|
| 205 | + $redirectSrcMatch = $redirect[ 'redirectSrcMatch' ] ?? 'pathonly'; |
|
| 206 | 206 | switch ($redirectSrcMatch) { |
| 207 | 207 | case 'pathonly': |
| 208 | 208 | $url = $pathOnly; |
@@ -214,11 +214,11 @@ discard block |
||
| 214 | 214 | $url = $pathOnly; |
| 215 | 215 | break; |
| 216 | 216 | } |
| 217 | - $dest = $redirect['redirectDestUrl']; |
|
| 217 | + $dest = $redirect[ 'redirectDestUrl' ]; |
|
| 218 | 218 | // If this isn't a full URL, make it one based on the appropriate site |
| 219 | 219 | if (!UrlHelper::isFullUrl($dest)) { |
| 220 | 220 | try { |
| 221 | - $dest = UrlHelper::siteUrl($dest, null, null, $redirect['siteId'] ?? null); |
|
| 221 | + $dest = UrlHelper::siteUrl($dest, null, null, $redirect[ 'siteId' ] ?? null); |
|
| 222 | 222 | } catch (\yii\base\Exception $e) { |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -228,12 +228,12 @@ discard block |
||
| 228 | 228 | $dest .= '?' . $request->getQueryStringWithoutPath(); |
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | - $status = $redirect['redirectHttpCode']; |
|
| 231 | + $status = $redirect[ 'redirectHttpCode' ]; |
|
| 232 | 232 | Craft::info( |
| 233 | 233 | Craft::t( |
| 234 | 234 | 'retour', |
| 235 | 235 | 'Redirecting {url} to {dest} with status {status}', |
| 236 | - ['url' => $url, 'dest' => $dest, 'status' => $status] |
|
| 236 | + [ 'url' => $url, 'dest' => $dest, 'status' => $status ] |
|
| 237 | 237 | ), |
| 238 | 238 | __METHOD__ |
| 239 | 239 | ); |
@@ -315,13 +315,13 @@ discard block |
||
| 315 | 315 | public function getRedirectFromCache($url, int $siteId = 0) |
| 316 | 316 | { |
| 317 | 317 | $cache = Craft::$app->getCache(); |
| 318 | - $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
| 318 | + $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
| 319 | 319 | $redirect = $cache->get($cacheKey); |
| 320 | 320 | Craft::info( |
| 321 | 321 | Craft::t( |
| 322 | 322 | 'retour', |
| 323 | 323 | 'Cached redirect hit for {url}', |
| 324 | - ['url' => $url] |
|
| 324 | + [ 'url' => $url ] |
|
| 325 | 325 | ), |
| 326 | 326 | __METHOD__ |
| 327 | 327 | ); |
@@ -343,12 +343,12 @@ discard block |
||
| 343 | 343 | } catch (SiteNotFoundException $e) { |
| 344 | 344 | $siteId = 1; |
| 345 | 345 | } |
| 346 | - $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
| 346 | + $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
| 347 | 347 | // Create the dependency tags |
| 348 | 348 | $dependency = new TagDependency([ |
| 349 | 349 | 'tags' => [ |
| 350 | 350 | $this::GLOBAL_REDIRECTS_CACHE_TAG, |
| 351 | - $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId, |
|
| 351 | + $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId, |
|
| 352 | 352 | ], |
| 353 | 353 | ]); |
| 354 | 354 | $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency); |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | Craft::t( |
| 357 | 357 | 'retour', |
| 358 | 358 | 'Cached redirect saved for {url}', |
| 359 | - ['url' => $url] |
|
| 359 | + [ 'url' => $url ] |
|
| 360 | 360 | ), |
| 361 | 361 | __METHOD__ |
| 362 | 362 | ); |
@@ -386,8 +386,8 @@ discard block |
||
| 386 | 386 | // Iterate through the redirects |
| 387 | 387 | foreach ($redirects as $redirect) { |
| 388 | 388 | // Figure out what type of source matching to do |
| 389 | - $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly'; |
|
| 390 | - $redirectEnabled = (bool)$redirect['enabled']; |
|
| 389 | + $redirectSrcMatch = $redirect[ 'redirectSrcMatch' ] ?? 'pathonly'; |
|
| 390 | + $redirectEnabled = (bool) $redirect[ 'enabled' ]; |
|
| 391 | 391 | if ($redirectEnabled === true) { |
| 392 | 392 | switch ($redirectSrcMatch) { |
| 393 | 393 | case 'pathonly': |
@@ -400,11 +400,11 @@ discard block |
||
| 400 | 400 | $url = $pathOnly; |
| 401 | 401 | break; |
| 402 | 402 | } |
| 403 | - $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound'; |
|
| 403 | + $redirectMatchType = $redirect[ 'redirectMatchType' ] ?? 'notfound'; |
|
| 404 | 404 | switch ($redirectMatchType) { |
| 405 | 405 | // Do a straight up match |
| 406 | 406 | case 'exactmatch': |
| 407 | - if (strcasecmp($redirect['redirectSrcUrlParsed'], $url) === 0) { |
|
| 407 | + if (strcasecmp($redirect[ 'redirectSrcUrlParsed' ], $url) === 0) { |
|
| 408 | 408 | $this->incrementRedirectHitCount($redirect); |
| 409 | 409 | $this->saveRedirectToCache($url, $redirect); |
| 410 | 410 | |
@@ -414,14 +414,14 @@ discard block |
||
| 414 | 414 | |
| 415 | 415 | // Do a regex match |
| 416 | 416 | case 'regexmatch': |
| 417 | - $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i'; |
|
| 417 | + $matchRegEx = '`' . $redirect[ 'redirectSrcUrlParsed' ] . '`i'; |
|
| 418 | 418 | if (preg_match($matchRegEx, $url) === 1) { |
| 419 | 419 | $this->incrementRedirectHitCount($redirect); |
| 420 | 420 | // If we're not associated with an EntryID, handle capture group replacement |
| 421 | - if ((int)$redirect['associatedElementId'] === 0) { |
|
| 422 | - $redirect['redirectDestUrl'] = preg_replace( |
|
| 421 | + if ((int) $redirect[ 'associatedElementId' ] === 0) { |
|
| 422 | + $redirect[ 'redirectDestUrl' ] = preg_replace( |
|
| 423 | 423 | $matchRegEx, |
| 424 | - $redirect['redirectDestUrl'], |
|
| 424 | + $redirect[ 'redirectDestUrl' ], |
|
| 425 | 425 | $url |
| 426 | 426 | ); |
| 427 | 427 | } |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | 'redirect' => &$redirect, |
| 441 | 441 | ], |
| 442 | 442 | ]; |
| 443 | - $result = \call_user_func_array([$plugin, 'retourMatch'], $args); |
|
| 443 | + $result = \call_user_func_array([ $plugin, 'retourMatch' ], $args); |
|
| 444 | 444 | if ($result) { |
| 445 | 445 | $this->incrementRedirectHitCount($redirect); |
| 446 | 446 | $this->saveRedirectToCache($url, $redirect); |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | Craft::t( |
| 468 | 468 | 'retour', |
| 469 | 469 | 'Not handled-> full URL: {fullUrl}, path only: {pathOnly}', |
| 470 | - ['fullUrl' => $fullUrl, 'pathOnly' => $pathOnly] |
|
| 470 | + [ 'fullUrl' => $fullUrl, 'pathOnly' => $pathOnly ] |
|
| 471 | 471 | ), |
| 472 | 472 | __METHOD__ |
| 473 | 473 | ); |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) { |
| 513 | 513 | /** @var Plugin $plugin */ |
| 514 | 514 | if (method_exists($plugin, 'retourMatch')) { |
| 515 | - $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match'); |
|
| 515 | + $result[ $plugin->getHandle() ] = $plugin->name . Craft::t('retour', ' Match'); |
|
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | |
@@ -533,12 +533,12 @@ discard block |
||
| 533 | 533 | } |
| 534 | 534 | // Query the db table |
| 535 | 535 | $query = (new Query()) |
| 536 | - ->from(['{{%retour_static_redirects}}']) |
|
| 536 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
| 537 | 537 | ->orderBy('redirectMatchType ASC, redirectSrcMatch ASC, hitCount DESC'); |
| 538 | 538 | if ($siteId) { |
| 539 | 539 | $query |
| 540 | - ->where(['siteId' => $siteId]) |
|
| 541 | - ->orWhere(['siteId' => null]); |
|
| 540 | + ->where([ 'siteId' => $siteId ]) |
|
| 541 | + ->orWhere([ 'siteId' => null ]); |
|
| 542 | 542 | } |
| 543 | 543 | if ($limit) { |
| 544 | 544 | $query->limit($limit); |
@@ -561,8 +561,8 @@ discard block |
||
| 561 | 561 | { |
| 562 | 562 | // Query the db table |
| 563 | 563 | $redirect = (new Query()) |
| 564 | - ->from(['{{%retour_static_redirects}}']) |
|
| 565 | - ->where(['id' => $id]) |
|
| 564 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
| 565 | + ->where([ 'id' => $id ]) |
|
| 566 | 566 | ->one(); |
| 567 | 567 | |
| 568 | 568 | return $redirect; |
@@ -580,16 +580,16 @@ discard block |
||
| 580 | 580 | { |
| 581 | 581 | // Query the db table |
| 582 | 582 | $query = (new Query()) |
| 583 | - ->from(['{{%retour_static_redirects}}']) |
|
| 584 | - ->where(['redirectSrcUrl' => $redirectSrcUrl]) |
|
| 583 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
| 584 | + ->where([ 'redirectSrcUrl' => $redirectSrcUrl ]) |
|
| 585 | 585 | ; |
| 586 | 586 | if ($siteId) { |
| 587 | 587 | $query |
| 588 | - ->andWhere(['or', [ |
|
| 588 | + ->andWhere([ 'or', [ |
|
| 589 | 589 | 'siteId' => $siteId, |
| 590 | 590 | ], [ |
| 591 | 591 | 'siteId' => null, |
| 592 | - ]]); |
|
| 592 | + ] ]); |
|
| 593 | 593 | } |
| 594 | 594 | $redirect = $query->one(); |
| 595 | 595 | |
@@ -631,13 +631,13 @@ discard block |
||
| 631 | 631 | { |
| 632 | 632 | if ($redirectConfig !== null) { |
| 633 | 633 | $db = Craft::$app->getDb(); |
| 634 | - $redirectConfig['hitCount']++; |
|
| 635 | - $redirectConfig['hitLastTime'] = Db::prepareDateForDb(new \DateTime()); |
|
| 634 | + $redirectConfig[ 'hitCount' ]++; |
|
| 635 | + $redirectConfig[ 'hitLastTime' ] = Db::prepareDateForDb(new \DateTime()); |
|
| 636 | 636 | Craft::debug( |
| 637 | 637 | Craft::t( |
| 638 | 638 | 'retour', |
| 639 | 639 | 'Incrementing statistics for: {redirect}', |
| 640 | - ['redirect' => print_r($redirectConfig, true)] |
|
| 640 | + [ 'redirect' => print_r($redirectConfig, true) ] |
|
| 641 | 641 | ), |
| 642 | 642 | __METHOD__ |
| 643 | 643 | ); |
@@ -646,14 +646,14 @@ discard block |
||
| 646 | 646 | $rowsAffected = $db->createCommand()->update( |
| 647 | 647 | '{{%retour_static_redirects}}', |
| 648 | 648 | [ |
| 649 | - 'hitCount' => $redirectConfig['hitCount'], |
|
| 650 | - 'hitLastTime' => $redirectConfig['hitLastTime'], |
|
| 649 | + 'hitCount' => $redirectConfig[ 'hitCount' ], |
|
| 650 | + 'hitLastTime' => $redirectConfig[ 'hitLastTime' ], |
|
| 651 | 651 | ], |
| 652 | 652 | [ |
| 653 | - 'id' => $redirectConfig['id'], |
|
| 653 | + 'id' => $redirectConfig[ 'id' ], |
|
| 654 | 654 | ] |
| 655 | 655 | )->execute(); |
| 656 | - Craft::debug('Rows affected: '.$rowsAffected, __METHOD__); |
|
| 656 | + Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__); |
|
| 657 | 657 | } catch (\Exception $e) { |
| 658 | 658 | Craft::error($e->getMessage(), __METHOD__); |
| 659 | 659 | } |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | Craft::t( |
| 673 | 673 | 'retour', |
| 674 | 674 | 'Error validating redirect {id}: {errors}', |
| 675 | - ['id' => $redirect->id, 'errors' => print_r($redirect->getErrors(), true)] |
|
| 675 | + [ 'id' => $redirect->id, 'errors' => print_r($redirect->getErrors(), true) ] |
|
| 676 | 676 | ), |
| 677 | 677 | __METHOD__ |
| 678 | 678 | ); |
@@ -682,32 +682,32 @@ discard block |
||
| 682 | 682 | // Get the validated model attributes and save them to the db |
| 683 | 683 | $redirectConfig = $redirect->getAttributes(); |
| 684 | 684 | // 0 for a siteId needs to be converted to null |
| 685 | - if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) { |
|
| 686 | - $redirectConfig['siteId'] = null; |
|
| 685 | + if (empty($redirectConfig[ 'siteId' ]) || (int) $redirectConfig[ 'siteId' ] === 0) { |
|
| 686 | + $redirectConfig[ 'siteId' ] = null; |
|
| 687 | 687 | } |
| 688 | 688 | // Throw an event to before saving the redirect |
| 689 | 689 | $db = Craft::$app->getDb(); |
| 690 | 690 | // See if a redirect exists with this source URL already |
| 691 | - if ((int)$redirectConfig['id'] === 0) { |
|
| 691 | + if ((int) $redirectConfig[ 'id' ] === 0) { |
|
| 692 | 692 | // Query the db table |
| 693 | 693 | $redirect = (new Query()) |
| 694 | - ->from(['{{%retour_static_redirects}}']) |
|
| 695 | - ->where(['redirectSrcUrlParsed' => $redirectConfig['redirectSrcUrlParsed']]) |
|
| 696 | - ->andWhere(['siteId' => $redirectConfig['siteId']]) |
|
| 694 | + ->from([ '{{%retour_static_redirects}}' ]) |
|
| 695 | + ->where([ 'redirectSrcUrlParsed' => $redirectConfig[ 'redirectSrcUrlParsed' ] ]) |
|
| 696 | + ->andWhere([ 'siteId' => $redirectConfig[ 'siteId' ] ]) |
|
| 697 | 697 | ->one(); |
| 698 | 698 | // If it exists, update it rather than having duplicates |
| 699 | 699 | if (!empty($redirect)) { |
| 700 | - $redirectConfig['id'] = $redirect['id']; |
|
| 700 | + $redirectConfig[ 'id' ] = $redirect[ 'id' ]; |
|
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | 703 | // Trigger a 'beforeSaveRedirect' event |
| 704 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
| 704 | + $isNew = (int) $redirectConfig[ 'id' ] === 0; |
|
| 705 | 705 | $event = new RedirectEvent([ |
| 706 | 706 | 'isNew' => $isNew, |
| 707 | - 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'], |
|
| 708 | - 'destinationUrl' => $redirectConfig['redirectDestUrl'], |
|
| 709 | - 'matchType' => $redirectConfig['redirectSrcMatch'], |
|
| 710 | - 'redirectType' => $redirectConfig['redirectHttpCode'], |
|
| 707 | + 'legacyUrl' => $redirectConfig[ 'redirectSrcUrlParsed' ], |
|
| 708 | + 'destinationUrl' => $redirectConfig[ 'redirectDestUrl' ], |
|
| 709 | + 'matchType' => $redirectConfig[ 'redirectSrcMatch' ], |
|
| 710 | + 'redirectType' => $redirectConfig[ 'redirectHttpCode' ], |
|
| 711 | 711 | ]); |
| 712 | 712 | $this->trigger(self::EVENT_BEFORE_SAVE_REDIRECT, $event); |
| 713 | 713 | if (!$event->isValid) { |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | Craft::t( |
| 720 | 720 | 'retour', |
| 721 | 721 | 'Updating existing redirect: {redirect}', |
| 722 | - ['redirect' => print_r($redirectConfig, true)] |
|
| 722 | + [ 'redirect' => print_r($redirectConfig, true) ] |
|
| 723 | 723 | ), |
| 724 | 724 | __METHOD__ |
| 725 | 725 | ); |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | '{{%retour_static_redirects}}', |
| 730 | 730 | $redirectConfig, |
| 731 | 731 | [ |
| 732 | - 'id' => $redirectConfig['id'], |
|
| 732 | + 'id' => $redirectConfig[ 'id' ], |
|
| 733 | 733 | ] |
| 734 | 734 | )->execute(); |
| 735 | 735 | } catch (Exception $e) { |
@@ -740,11 +740,11 @@ discard block |
||
| 740 | 740 | Craft::t( |
| 741 | 741 | 'retour', |
| 742 | 742 | 'Creating new redirect: {redirect}', |
| 743 | - ['redirect' => print_r($redirectConfig, true)] |
|
| 743 | + [ 'redirect' => print_r($redirectConfig, true) ] |
|
| 744 | 744 | ), |
| 745 | 745 | __METHOD__ |
| 746 | 746 | ); |
| 747 | - unset($redirectConfig['id']); |
|
| 747 | + unset($redirectConfig[ 'id' ]); |
|
| 748 | 748 | // Create a new record |
| 749 | 749 | try { |
| 750 | 750 | $db->createCommand()->insert( |
@@ -757,15 +757,15 @@ discard block |
||
| 757 | 757 | } |
| 758 | 758 | // To prevent redirect loops, see if any static redirects have our redirectDestUrl as their redirectSrcUrl |
| 759 | 759 | $testRedirectConfig = $this->getRedirectByRedirectSrcUrl( |
| 760 | - $redirectConfig['redirectDestUrl'], |
|
| 761 | - $redirectConfig['siteId'] |
|
| 760 | + $redirectConfig[ 'redirectDestUrl' ], |
|
| 761 | + $redirectConfig[ 'siteId' ] |
|
| 762 | 762 | ); |
| 763 | 763 | if ($testRedirectConfig !== null) { |
| 764 | 764 | Craft::debug( |
| 765 | 765 | Craft::t( |
| 766 | 766 | 'retour', |
| 767 | 767 | 'Deleting redirect to prevent a loop: {redirect}', |
| 768 | - ['redirect' => print_r($testRedirectConfig, true)] |
|
| 768 | + [ 'redirect' => print_r($testRedirectConfig, true) ] |
|
| 769 | 769 | ), |
| 770 | 770 | __METHOD__ |
| 771 | 771 | ); |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | try { |
| 774 | 774 | $db->createCommand()->delete( |
| 775 | 775 | '{{%retour_static_redirects}}', |
| 776 | - ['id' => $testRedirectConfig['id']] |
|
| 776 | + [ 'id' => $testRedirectConfig[ 'id' ] ] |
|
| 777 | 777 | )->execute(); |
| 778 | 778 | } catch (Exception $e) { |
| 779 | 779 | Craft::error($e->getMessage(), __METHOD__); |
@@ -806,10 +806,10 @@ discard block |
||
| 806 | 806 | */ |
| 807 | 807 | public function excludeUri($uri): bool |
| 808 | 808 | { |
| 809 | - $uri = '/'.ltrim($uri, '/'); |
|
| 809 | + $uri = '/' . ltrim($uri, '/'); |
|
| 810 | 810 | if (!empty(Retour::$settings->excludePatterns)) { |
| 811 | 811 | foreach (Retour::$settings->excludePatterns as $excludePattern) { |
| 812 | - $pattern = '`'.$excludePattern['pattern'].'`i'; |
|
| 812 | + $pattern = '`' . $excludePattern[ 'pattern' ] . '`i'; |
|
| 813 | 813 | if (preg_match($pattern, $uri) === 1) { |
| 814 | 814 | return true; |
| 815 | 815 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | /** |
| 111 | 111 | * @var array The URIs for the element before it was saved |
| 112 | 112 | */ |
| 113 | - public $oldElementUris = []; |
|
| 113 | + public $oldElementUris = [ ]; |
|
| 114 | 114 | |
| 115 | 115 | // Public Methods |
| 116 | 116 | // ========================================================================= |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | Craft::t( |
| 143 | 143 | 'retour', |
| 144 | 144 | '{name} plugin loaded', |
| 145 | - ['name' => $this->name] |
|
| 145 | + [ 'name' => $this->name ] |
|
| 146 | 146 | ), |
| 147 | 147 | __METHOD__ |
| 148 | 148 | ); |
@@ -162,18 +162,18 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function getCpNavItem() |
| 164 | 164 | { |
| 165 | - $subNavs = []; |
|
| 165 | + $subNavs = [ ]; |
|
| 166 | 166 | $navItem = parent::getCpNavItem(); |
| 167 | 167 | $currentUser = Craft::$app->getUser()->getIdentity(); |
| 168 | 168 | // Only show sub-navs the user has permission to view |
| 169 | 169 | if ($currentUser->can('retour:dashboard')) { |
| 170 | - $subNavs['dashboard'] = [ |
|
| 170 | + $subNavs[ 'dashboard' ] = [ |
|
| 171 | 171 | 'label' => 'Dashboard', |
| 172 | 172 | 'url' => 'retour/dashboard', |
| 173 | 173 | ]; |
| 174 | 174 | } |
| 175 | 175 | if ($currentUser->can('retour:redirects')) { |
| 176 | - $subNavs['redirects'] = [ |
|
| 176 | + $subNavs[ 'redirects' ] = [ |
|
| 177 | 177 | 'label' => 'Redirects', |
| 178 | 178 | 'url' => 'retour/redirects', |
| 179 | 179 | ]; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $editableSettings = false; |
| 185 | 185 | } |
| 186 | 186 | if ($currentUser->can('retour:settings') && $editableSettings) { |
| 187 | - $subNavs['settings'] = [ |
|
| 187 | + $subNavs[ 'settings' ] = [ |
|
| 188 | 188 | 'label' => 'Settings', |
| 189 | 189 | 'url' => 'retour/settings', |
| 190 | 190 | ]; |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | Event::on( |
| 244 | 244 | ClearCaches::class, |
| 245 | 245 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 246 | - function (RegisterCacheOptionsEvent $event) { |
|
| 246 | + function(RegisterCacheOptionsEvent $event) { |
|
| 247 | 247 | Craft::debug( |
| 248 | 248 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
| 249 | 249 | __METHOD__ |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | Event::on( |
| 260 | 260 | Plugins::class, |
| 261 | 261 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 262 | - function (PluginEvent $event) { |
|
| 262 | + function(PluginEvent $event) { |
|
| 263 | 263 | if ($event->plugin === $this) { |
| 264 | 264 | // Invalidate our caches after we've been installed |
| 265 | 265 | $this->clearAllCaches(); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | Event::on( |
| 287 | 287 | CraftVariable::class, |
| 288 | 288 | CraftVariable::EVENT_INIT, |
| 289 | - function (Event $event) { |
|
| 289 | + function(Event $event) { |
|
| 290 | 290 | /** @var CraftVariable $variable */ |
| 291 | 291 | $variable = $event->sender; |
| 292 | 292 | $variable->set('retour', RetourVariable::class); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | Event::on( |
| 297 | 297 | Elements::class, |
| 298 | 298 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
| 299 | - function (ElementEvent $event) { |
|
| 299 | + function(ElementEvent $event) { |
|
| 300 | 300 | Craft::debug( |
| 301 | 301 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
| 302 | 302 | __METHOD__ |
@@ -321,8 +321,8 @@ discard block |
||
| 321 | 321 | if (strpos($element->uri, '__temp_') === false && !$element->propagating) { |
| 322 | 322 | // Stash the old URLs by element id, and do so only once, |
| 323 | 323 | // in case we are called more than once per request |
| 324 | - if (empty($this->oldElementUris[$element->id])) { |
|
| 325 | - $this->oldElementUris[$element->id] = $this->getAllElementUris($element); |
|
| 324 | + if (empty($this->oldElementUris[ $element->id ])) { |
|
| 325 | + $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element); |
|
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | } |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | Event::on( |
| 334 | 334 | Elements::class, |
| 335 | 335 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
| 336 | - function (ElementEvent $event) { |
|
| 336 | + function(ElementEvent $event) { |
|
| 337 | 337 | Craft::debug( |
| 338 | 338 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
| 339 | 339 | __METHOD__ |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | Event::on( |
| 356 | 356 | Plugins::class, |
| 357 | 357 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 358 | - function () { |
|
| 358 | + function() { |
|
| 359 | 359 | // Install these only after all other plugins have loaded |
| 360 | 360 | $request = Craft::$app->getRequest(); |
| 361 | 361 | // Only respond to non-console site requests |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | Event::on( |
| 374 | 374 | Schema::class, |
| 375 | 375 | AlterSchemaFields::EVENT, |
| 376 | - [GetCraftQLSchema::class, 'handle'] |
|
| 376 | + [ GetCraftQLSchema::class, 'handle' ] |
|
| 377 | 377 | ); |
| 378 | 378 | } |
| 379 | 379 | } |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | Event::on( |
| 388 | 388 | UrlManager::class, |
| 389 | 389 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 390 | - function (RegisterUrlRulesEvent $event) { |
|
| 390 | + function(RegisterUrlRulesEvent $event) { |
|
| 391 | 391 | Craft::debug( |
| 392 | 392 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 393 | 393 | __METHOD__ |
@@ -410,15 +410,15 @@ discard block |
||
| 410 | 410 | Event::on( |
| 411 | 411 | Dashboard::class, |
| 412 | 412 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
| 413 | - function (RegisterComponentTypesEvent $event) { |
|
| 414 | - $event->types[] = RetourWidget::class; |
|
| 413 | + function(RegisterComponentTypesEvent $event) { |
|
| 414 | + $event->types[ ] = RetourWidget::class; |
|
| 415 | 415 | } |
| 416 | 416 | ); |
| 417 | 417 | // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES |
| 418 | 418 | Event::on( |
| 419 | 419 | UrlManager::class, |
| 420 | 420 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 421 | - function (RegisterUrlRulesEvent $event) { |
|
| 421 | + function(RegisterUrlRulesEvent $event) { |
|
| 422 | 422 | Craft::debug( |
| 423 | 423 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 424 | 424 | __METHOD__ |
@@ -434,13 +434,13 @@ discard block |
||
| 434 | 434 | Event::on( |
| 435 | 435 | UserPermissions::class, |
| 436 | 436 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 437 | - function (RegisterUserPermissionsEvent $event) { |
|
| 437 | + function(RegisterUserPermissionsEvent $event) { |
|
| 438 | 438 | Craft::debug( |
| 439 | 439 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 440 | 440 | __METHOD__ |
| 441 | 441 | ); |
| 442 | 442 | // Register our custom permissions |
| 443 | - $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions(); |
|
| 443 | + $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions(); |
|
| 444 | 444 | } |
| 445 | 445 | ); |
| 446 | 446 | } |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | Event::on( |
| 457 | 457 | ErrorHandler::class, |
| 458 | 458 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
| 459 | - function (ExceptionEvent $event) { |
|
| 459 | + function(ExceptionEvent $event) { |
|
| 460 | 460 | Craft::debug( |
| 461 | 461 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
| 462 | 462 | __METHOD__ |
@@ -499,16 +499,16 @@ discard block |
||
| 499 | 499 | protected function handleElementUriChange(Element $element) |
| 500 | 500 | { |
| 501 | 501 | $uris = $this->getAllElementUris($element); |
| 502 | - if (!empty($this->oldElementUris[$element->id])) { |
|
| 503 | - $oldElementUris = $this->oldElementUris[$element->id]; |
|
| 502 | + if (!empty($this->oldElementUris[ $element->id ])) { |
|
| 503 | + $oldElementUris = $this->oldElementUris[ $element->id ]; |
|
| 504 | 504 | foreach ($uris as $siteId => $newUri) { |
| 505 | - if (!empty($oldElementUris[$siteId])) { |
|
| 506 | - $oldUri = $oldElementUris[$siteId]; |
|
| 505 | + if (!empty($oldElementUris[ $siteId ])) { |
|
| 506 | + $oldUri = $oldElementUris[ $siteId ]; |
|
| 507 | 507 | Craft::debug( |
| 508 | 508 | Craft::t( |
| 509 | 509 | 'retour', |
| 510 | 510 | 'Comparing old: {oldUri} to new: {newUri}', |
| 511 | - ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)] |
|
| 511 | + [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ] |
|
| 512 | 512 | ), |
| 513 | 513 | __METHOD__ |
| 514 | 514 | ); |
@@ -548,13 +548,13 @@ discard block |
||
| 548 | 548 | */ |
| 549 | 549 | protected function getAllElementUris(Element $element): array |
| 550 | 550 | { |
| 551 | - $uris = []; |
|
| 551 | + $uris = [ ]; |
|
| 552 | 552 | if (!ElementHelper::isDraftOrRevision($element)) { |
| 553 | 553 | $sites = Craft::$app->getSites()->getAllSites(); |
| 554 | 554 | foreach ($sites as $site) { |
| 555 | 555 | $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id); |
| 556 | 556 | if ($uri !== null) { |
| 557 | - $uris[$site->id] = $uri; |
|
| 557 | + $uris[ $site->id ] = $uri; |
|
| 558 | 558 | } |
| 559 | 559 | } |
| 560 | 560 | } |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | Craft::t( |
| 564 | 564 | 'retour', |
| 565 | 565 | 'Getting Element URIs: {uris}', |
| 566 | - ['uris' => print_r($uris, true)] |
|
| 566 | + [ 'uris' => print_r($uris, true) ] |
|
| 567 | 567 | ), |
| 568 | 568 | __METHOD__ |
| 569 | 569 | ); |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | [ |
| 628 | 628 | 'key' => 'retour-redirect-caches', |
| 629 | 629 | 'label' => Craft::t('retour', 'Retour redirect caches'), |
| 630 | - 'action' => [self::$plugin->redirects, 'invalidateCaches'], |
|
| 630 | + 'action' => [ self::$plugin->redirects, 'invalidateCaches' ], |
|
| 631 | 631 | ], |
| 632 | 632 | ]; |
| 633 | 633 | } |