@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | Event::on( |
243 | 243 | ClearCaches::class, |
244 | 244 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
245 | - function (RegisterCacheOptionsEvent $event) { |
|
245 | + function(RegisterCacheOptionsEvent $event) { |
|
246 | 246 | Craft::debug( |
247 | 247 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
248 | 248 | __METHOD__ |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | Event::on( |
259 | 259 | Plugins::class, |
260 | 260 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
261 | - function (PluginEvent $event) { |
|
261 | + function(PluginEvent $event) { |
|
262 | 262 | if ($event->plugin === $this) { |
263 | 263 | // Invalidate our caches after we've been installed |
264 | 264 | $this->clearAllCaches(); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | Event::on( |
298 | 298 | CraftVariable::class, |
299 | 299 | CraftVariable::EVENT_INIT, |
300 | - function (Event $event) { |
|
300 | + function(Event $event) { |
|
301 | 301 | /** @var CraftVariable $variable */ |
302 | 302 | $variable = $event->sender; |
303 | 303 | $variable->set('retour', [ |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | } |
308 | 308 | ); |
309 | 309 | |
310 | - $prepareRedirectOnElementChange = function (ElementEvent $event) { |
|
310 | + $prepareRedirectOnElementChange = function(ElementEvent $event) { |
|
311 | 311 | /** @var Element $element */ |
312 | 312 | $element = $event->element; |
313 | 313 | if (!$event->isNew && $element->getUrl() !== null && !$element->propagating) { |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } |
329 | 329 | }; |
330 | 330 | |
331 | - $insertRedirectOnElementChange = function (ElementEvent $event) { |
|
331 | + $insertRedirectOnElementChange = function(ElementEvent $event) { |
|
332 | 332 | /** @var Element $element */ |
333 | 333 | $element = $event->element; |
334 | 334 | if ($element !== null && !$event->isNew && $element->getUrl() !== null) { |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | Event::on( |
347 | 347 | Elements::class, |
348 | 348 | Elements::EVENT_BEFORE_SAVE_ELEMENT, |
349 | - static function (ElementEvent $event) use ($prepareRedirectOnElementChange) { |
|
349 | + static function(ElementEvent $event) use ($prepareRedirectOnElementChange) { |
|
350 | 350 | Craft::debug( |
351 | 351 | 'Elements::EVENT_BEFORE_SAVE_ELEMENT', |
352 | 352 | __METHOD__ |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | Event::on( |
359 | 359 | Elements::class, |
360 | 360 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
361 | - static function (ElementEvent $event) use ($insertRedirectOnElementChange) { |
|
361 | + static function(ElementEvent $event) use ($insertRedirectOnElementChange) { |
|
362 | 362 | Craft::debug( |
363 | 363 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
364 | 364 | __METHOD__ |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | Event::on( |
371 | 371 | Elements::class, |
372 | 372 | Elements::EVENT_BEFORE_UPDATE_SLUG_AND_URI, |
373 | - static function (ElementEvent $event) use ($prepareRedirectOnElementChange) { |
|
373 | + static function(ElementEvent $event) use ($prepareRedirectOnElementChange) { |
|
374 | 374 | Craft::debug( |
375 | 375 | 'Elements::EVENT_BEFORE_UPDATE_SLUG_AND_URI', |
376 | 376 | __METHOD__ |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | Event::on( |
383 | 383 | Elements::class, |
384 | 384 | Elements::EVENT_AFTER_UPDATE_SLUG_AND_URI, |
385 | - static function (ElementEvent $event) use ($insertRedirectOnElementChange) { |
|
385 | + static function(ElementEvent $event) use ($insertRedirectOnElementChange) { |
|
386 | 386 | Craft::debug( |
387 | 387 | 'Elements::EVENT_AFTER_UPDATE_SLUG_AND_URI', |
388 | 388 | __METHOD__ |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | Event::on( |
395 | 395 | Plugins::class, |
396 | 396 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
397 | - function () { |
|
397 | + function() { |
|
398 | 398 | // Install these only after all other plugins have loaded |
399 | 399 | $request = Craft::$app->getRequest(); |
400 | 400 | // Only respond to non-console site requests |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | Event::on( |
412 | 412 | Fields::class, |
413 | 413 | Fields::EVENT_REGISTER_FIELD_TYPES, |
414 | - function (RegisterComponentTypesEvent $event) { |
|
414 | + function(RegisterComponentTypesEvent $event) { |
|
415 | 415 | $event->types[] = ShortLinkField::class; |
416 | 416 | } |
417 | 417 | ); |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | Event::on( |
420 | 420 | Gql::class, |
421 | 421 | Gql::EVENT_REGISTER_GQL_TYPES, |
422 | - static function (RegisterGqlTypesEvent $event) { |
|
422 | + static function(RegisterGqlTypesEvent $event) { |
|
423 | 423 | Craft::debug( |
424 | 424 | 'Gql::EVENT_REGISTER_GQL_TYPES', |
425 | 425 | __METHOD__ |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | Event::on( |
432 | 432 | Gql::class, |
433 | 433 | Gql::EVENT_REGISTER_GQL_QUERIES, |
434 | - static function (RegisterGqlQueriesEvent $event) { |
|
434 | + static function(RegisterGqlQueriesEvent $event) { |
|
435 | 435 | Craft::debug( |
436 | 436 | 'Gql::EVENT_REGISTER_GQL_QUERIES', |
437 | 437 | __METHOD__ |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | Event::on( |
447 | 447 | Gql::class, |
448 | 448 | Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS, |
449 | - static function (RegisterGqlSchemaComponentsEvent $event) { |
|
449 | + static function(RegisterGqlSchemaComponentsEvent $event) { |
|
450 | 450 | Craft::debug( |
451 | 451 | 'Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS', |
452 | 452 | __METHOD__ |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | Event::on( |
469 | 469 | ErrorHandler::class, |
470 | 470 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
471 | - static function (ExceptionEvent $event) { |
|
471 | + static function(ExceptionEvent $event) { |
|
472 | 472 | Craft::debug( |
473 | 473 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
474 | 474 | __METHOD__ |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | Event::on( |
507 | 507 | UrlManager::class, |
508 | 508 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
509 | - function (RegisterUrlRulesEvent $event) { |
|
509 | + function(RegisterUrlRulesEvent $event) { |
|
510 | 510 | Craft::debug( |
511 | 511 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
512 | 512 | __METHOD__ |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | Event::on( |
541 | 541 | Dashboard::class, |
542 | 542 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
543 | - function (RegisterComponentTypesEvent $event) { |
|
543 | + function(RegisterComponentTypesEvent $event) { |
|
544 | 544 | $currentUser = Craft::$app->getUser()->getIdentity(); |
545 | 545 | if ($currentUser->can('accessPlugin-retour')) { |
546 | 546 | $event->types[] = RetourWidget::class; |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | Event::on( |
552 | 552 | UrlManager::class, |
553 | 553 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
554 | - function (RegisterUrlRulesEvent $event) { |
|
554 | + function(RegisterUrlRulesEvent $event) { |
|
555 | 555 | Craft::debug( |
556 | 556 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
557 | 557 | __METHOD__ |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | Event::on( |
568 | 568 | UserPermissions::class, |
569 | 569 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
570 | - function (RegisterUserPermissionsEvent $event) { |
|
570 | + function(RegisterUserPermissionsEvent $event) { |
|
571 | 571 | Craft::debug( |
572 | 572 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
573 | 573 | __METHOD__ |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | // so we can't extract it from the passed in $config |
40 | 40 | $majorVersion = '5'; |
41 | 41 | // Dev server container name & port are based on the major version of this plugin |
42 | - $devPort = 3000 + (int)$majorVersion; |
|
43 | - $versionName = 'v' . $majorVersion; |
|
42 | + $devPort = 3000 + (int) $majorVersion; |
|
43 | + $versionName = 'v'.$majorVersion; |
|
44 | 44 | return [ |
45 | 45 | 'components' => [ |
46 | 46 | 'events' => Events::class, |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | 'assetClass' => RetourAsset::class, |
52 | 52 | 'checkDevServer' => true, |
53 | 53 | 'class' => VitePluginService::class, |
54 | - 'devServerInternal' => 'http://craft-retour-' . $versionName . '-buildchain-dev:' . $devPort, |
|
55 | - 'devServerPublic' => 'http://localhost:' . $devPort, |
|
54 | + 'devServerInternal' => 'http://craft-retour-'.$versionName.'-buildchain-dev:'.$devPort, |
|
55 | + 'devServerPublic' => 'http://localhost:'.$devPort, |
|
56 | 56 | 'errorEntry' => 'src/js/Retour.js', |
57 | 57 | 'useDevServer' => true, |
58 | 58 | ], |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | // Protected Properties |
90 | 90 | // ========================================================================= |
91 | 91 | |
92 | - protected array|bool|int $allowAnonymous = []; |
|
92 | + protected array | bool | int $allowAnonymous = []; |
|
93 | 93 | |
94 | 94 | // Public Methods |
95 | 95 | // ========================================================================= |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $variables['docsUrl'] = self::DOCUMENTATION_URL; |
207 | 207 | $variables['pluginName'] = $pluginName; |
208 | 208 | $variables['title'] = $templateTitle; |
209 | - $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
209 | + $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
210 | 210 | $variables['crumbs'] = [ |
211 | 211 | [ |
212 | 212 | 'label' => $pluginName, |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | ], |
215 | 215 | [ |
216 | 216 | 'label' => 'Redirects', |
217 | - 'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri), |
|
217 | + 'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri), |
|
218 | 218 | ], |
219 | 219 | ]; |
220 | 220 | $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}"; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $file = UploadedFile::getInstanceByName('file'); |
225 | 225 | if ($file !== null) { |
226 | 226 | $filename = uniqid($file->name, true); |
227 | - $filePath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $filename; |
|
227 | + $filePath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$filename; |
|
228 | 228 | $file->saveAs($filePath, false); |
229 | 229 | // Also save the file to the cache as a backup way to access it |
230 | 230 | $fileContents = @file_get_contents($filePath); |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $columns = ArrayHelper::filterEmptyStringsFromArray($columns); |
346 | 346 | $rowIndex = 1; |
347 | 347 | /** @phpstan-ignore-next-line */ |
348 | - $csv->each(function ($row) use ($headers, $columns, &$rowIndex, &$hasErrors) { |
|
348 | + $csv->each(function($row) use ($headers, $columns, &$rowIndex, &$hasErrors) { |
|
349 | 349 | $redirectConfig = [ |
350 | 350 | 'id' => 0, |
351 | 351 | ]; |
@@ -359,9 +359,9 @@ discard block |
||
359 | 359 | $index++; |
360 | 360 | } |
361 | 361 | $redirectDump = print_r($redirectConfig, true); |
362 | - Craft::debug("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
362 | + Craft::debug("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
363 | 363 | if (!Retour::$plugin->redirects->saveRedirect($redirectConfig)) { |
364 | - Craft::info("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
364 | + Craft::info("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
365 | 365 | $hasErrors = true; |
366 | 366 | } |
367 | 367 | $rowIndex++; |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | $index++; |
402 | 402 | } |
403 | 403 | $redirectDump = print_r($redirectConfig, true); |
404 | - Craft::debug("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
404 | + Craft::debug("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
405 | 405 | if (!Retour::$plugin->redirects->saveRedirect($redirectConfig)) { |
406 | - Craft::info("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
406 | + Craft::info("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
407 | 407 | $hasErrors = true; |
408 | 408 | } |
409 | 409 | $rowIndex++; |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | } |
440 | 440 | $csv->insertOne(array_values($columns)); |
441 | 441 | $csv->insertAll($data); |
442 | - $csv->output($filename . '.csv'); |
|
442 | + $csv->output($filename.'.csv'); |
|
443 | 443 | exit(0); |
444 | 444 | } |
445 | 445 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @inheritdoc |
37 | 37 | */ |
38 | - protected array|bool|int $allowAnonymous = [ |
|
38 | + protected array | bool | int $allowAnonymous = [ |
|
39 | 39 | ]; |
40 | 40 | |
41 | 41 | // Public Methods |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | 'COUNT(handledByRetour = 1 or null) as handled_cnt', |
80 | 80 | ]) |
81 | 81 | ->where("hitLastTime >= ( CURDATE() - INTERVAL '{$days}' DAY )"); |
82 | - if ((int)$siteId !== 0) { |
|
82 | + if ((int) $siteId !== 0) { |
|
83 | 83 | $query->andWhere(['siteId' => $siteId]); |
84 | 84 | } |
85 | 85 | $query |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | "COUNT(CASE WHEN \"handledByRetour\" = true THEN 1 END) as handled_cnt", |
98 | 98 | ]) |
99 | 99 | ->where("\"hitLastTime\" >= ( CURRENT_TIMESTAMP - INTERVAL '{$days} days' )"); |
100 | - if ((int)$siteId !== 0) { |
|
100 | + if ((int) $siteId !== 0) { |
|
101 | 101 | $query->andWhere(['siteId' => $siteId]); |
102 | 102 | } |
103 | 103 | $query |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | } |
162 | 162 | if ($stats) { |
163 | 163 | $data = [ |
164 | - (int)$stats, |
|
165 | - (int)$handledStats, |
|
164 | + (int) $stats, |
|
165 | + (int) $handledStats, |
|
166 | 166 | ]; |
167 | 167 | } |
168 | 168 |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | /** |
70 | 70 | * @inheritdoc |
71 | 71 | */ |
72 | - protected array|bool|int $allowAnonymous = [ |
|
72 | + protected array | bool | int $allowAnonymous = [ |
|
73 | 73 | ]; |
74 | 74 | |
75 | 75 | // Public Methods |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | ->orderBy([$sortField => $sortType]) |
125 | 125 | ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
126 | 126 | ->orFilterWhere(['like', 'referrerUrl', $filter]); |
127 | - if ((int)$siteId !== 0) { |
|
127 | + if ((int) $siteId !== 0) { |
|
128 | 128 | $query->andWhere(['siteId' => $siteId]); |
129 | 129 | } |
130 | 130 | if ($handled !== 'all') { |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | $stat['addLink'] = ''; |
147 | 147 | if (!$stat['handledByRetour']) { |
148 | - $encodedUrl = urlencode('/' . ltrim($stat['redirectSrcUrl'], '/')); |
|
148 | + $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/')); |
|
149 | 149 | // Add the siteId to the URL, but keep the current behavior of passing in siteId=0 for "all" |
150 | 150 | $statSiteId = $stat['siteId'] ?? 0; |
151 | 151 | try { |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } catch (SiteNotFoundException $e) { |
154 | 154 | $primarySite = null; |
155 | 155 | } |
156 | - if ($primarySite !== null && $statSiteId == (int)$primarySite->id) { |
|
156 | + if ($primarySite !== null && $statSiteId == (int) $primarySite->id) { |
|
157 | 157 | $statSiteId = 0; |
158 | 158 | } |
159 | 159 | $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [ |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | ->orderBy([$sortField => $sortType]) |
229 | 229 | ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
230 | 230 | ->orFilterWhere(['like', 'redirectDestUrl', $filter]); |
231 | - if ((int)$siteId !== 0) { |
|
231 | + if ((int) $siteId !== 0) { |
|
232 | 232 | $query->andWhere(['siteId' => $siteId]); |
233 | 233 | } |
234 | 234 | if ($shortLinks) { |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
273 | - $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect['id']); |
|
273 | + $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']); |
|
274 | 274 | } |
275 | 275 | // Format the data for the API |
276 | 276 | if ($redirects) { |