Passed
Push — develop ( c7a8b4...cee39f )
by Andrew
15:58
created
src/config.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
     // The number of milliseconds required between trimming of statistics
52 52
     'statisticsRateLimitMs' => 3600000,
53 53
 
54
-     // [Regular expressions](https://regexr.com/) to match URLs to exclude from tracking
54
+        // [Regular expressions](https://regexr.com/) to match URLs to exclude from tracking
55 55
     'excludePatterns' => [
56 56
     ],
57 57
 ];
Please login to merge, or discard this patch.
src/services/Statistics.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/listeners/GetCraftQLSchema.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -62,36 +62,36 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Retour.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     /**
105 105
      * @var array The URIs for the element before it was saved
106 106
      */
107
-    public $oldElementUris = [];
107
+    public $oldElementUris = [ ];
108 108
 
109 109
     // Public Methods
110 110
     // =========================================================================
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             Craft::t(
136 136
                 'retour',
137 137
                 '{name} plugin loaded',
138
-                ['name' => $this->name]
138
+                [ 'name' => $this->name ]
139 139
             ),
140 140
             __METHOD__
141 141
         );
@@ -155,18 +155,18 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function getCpNavItem()
157 157
     {
158
-        $subNavs = [];
158
+        $subNavs = [ ];
159 159
         $navItem = parent::getCpNavItem();
160 160
         $currentUser = Craft::$app->getUser()->getIdentity();
161 161
         // Only show sub-navs the user has permission to view
162 162
         if ($currentUser->can('retour:dashboard')) {
163
-            $subNavs['dashboard'] = [
163
+            $subNavs[ 'dashboard' ] = [
164 164
                 'label' => 'Dashboard',
165 165
                 'url' => 'retour/dashboard',
166 166
             ];
167 167
         }
168 168
         if ($currentUser->can('retour:redirects')) {
169
-            $subNavs['redirects'] = [
169
+            $subNavs[ 'redirects' ] = [
170 170
                 'label' => 'Redirects',
171 171
                 'url' => 'retour/redirects',
172 172
             ];
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             $editableSettings = false;
178 178
         }
179 179
         if ($currentUser->can('retour:settings') && $editableSettings) {
180
-            $subNavs['settings'] = [
180
+            $subNavs[ 'settings' ] = [
181 181
                 'label' => 'Settings',
182 182
                 'url' => 'retour/settings',
183 183
             ];
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
         Event::on(
237 237
             ClearCaches::class,
238 238
             ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
239
-            function (RegisterCacheOptionsEvent $event) {
239
+            function(RegisterCacheOptionsEvent $event) {
240 240
                 Craft::debug(
241 241
                     'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS',
242 242
                     __METHOD__
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         Event::on(
253 253
             Plugins::class,
254 254
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
255
-            function (PluginEvent $event) {
255
+            function(PluginEvent $event) {
256 256
                 if ($event->plugin === $this) {
257 257
                     // Invalidate our caches after we've been installed
258 258
                     $this->clearAllCaches();
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         Event::on(
280 280
             CraftVariable::class,
281 281
             CraftVariable::EVENT_INIT,
282
-            function (Event $event) {
282
+            function(Event $event) {
283 283
                 /** @var CraftVariable $variable */
284 284
                 $variable = $event->sender;
285 285
                 $variable->set('retour', RetourVariable::class);
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
         Event::on(
290 290
             Elements::class,
291 291
             Elements::EVENT_BEFORE_SAVE_ELEMENT,
292
-            function (ElementEvent $event) {
292
+            function(ElementEvent $event) {
293 293
                 Craft::debug(
294 294
                     'Elements::EVENT_BEFORE_SAVE_ELEMENT',
295 295
                     __METHOD__
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
                         if ($oldElement !== null) {
305 305
                             // Stash the old URLs by element id, and do so only once,
306 306
                             // in case we are called more than once per request
307
-                            if (empty($this->oldElementUris[$oldElement->id])) {
308
-                                $this->oldElementUris[$oldElement->id] = $this->getAllElementUris($oldElement);
307
+                            if (empty($this->oldElementUris[ $oldElement->id ])) {
308
+                                $this->oldElementUris[ $oldElement->id ] = $this->getAllElementUris($oldElement);
309 309
                             }
310 310
                         }
311 311
                     }
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
         Event::on(
317 317
             Elements::class,
318 318
             Elements::EVENT_AFTER_SAVE_ELEMENT,
319
-            function (ElementEvent $event) {
319
+            function(ElementEvent $event) {
320 320
                 Craft::debug(
321 321
                     'Elements::EVENT_AFTER_SAVE_ELEMENT',
322 322
                     __METHOD__
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
         Event::on(
333 333
             Plugins::class,
334 334
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
335
-            function () {
335
+            function() {
336 336
                 // Install these only after all other plugins have loaded
337 337
                 $request = Craft::$app->getRequest();
338 338
                 // Only respond to non-console site requests
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             Event::on(
351 351
                 Schema::class,
352 352
                 AlterSchemaFields::EVENT,
353
-                [GetCraftQLSchema::class, 'handle']
353
+                [ GetCraftQLSchema::class, 'handle' ]
354 354
             );
355 355
         }
356 356
     }
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
         Event::on(
365 365
             UrlManager::class,
366 366
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
367
-            function (RegisterUrlRulesEvent $event) {
367
+            function(RegisterUrlRulesEvent $event) {
368 368
                 Craft::debug(
369 369
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
370 370
                     __METHOD__
@@ -387,15 +387,15 @@  discard block
 block discarded – undo
387 387
         Event::on(
388 388
             Dashboard::class,
389 389
             Dashboard::EVENT_REGISTER_WIDGET_TYPES,
390
-            function (RegisterComponentTypesEvent $event) {
391
-                $event->types[] = RetourWidget::class;
390
+            function(RegisterComponentTypesEvent $event) {
391
+                $event->types[ ] = RetourWidget::class;
392 392
             }
393 393
         );
394 394
         // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES
395 395
         Event::on(
396 396
             UrlManager::class,
397 397
             UrlManager::EVENT_REGISTER_CP_URL_RULES,
398
-            function (RegisterUrlRulesEvent $event) {
398
+            function(RegisterUrlRulesEvent $event) {
399 399
                 Craft::debug(
400 400
                     'UrlManager::EVENT_REGISTER_CP_URL_RULES',
401 401
                     __METHOD__
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
         Event::on(
412 412
             UserPermissions::class,
413 413
             UserPermissions::EVENT_REGISTER_PERMISSIONS,
414
-            function (RegisterUserPermissionsEvent $event) {
414
+            function(RegisterUserPermissionsEvent $event) {
415 415
                 Craft::debug(
416 416
                     'UserPermissions::EVENT_REGISTER_PERMISSIONS',
417 417
                     __METHOD__
418 418
                 );
419 419
                 // Register our custom permissions
420
-                $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions();
420
+                $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions();
421 421
             }
422 422
         );
423 423
     }
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
         Event::on(
434 434
             ErrorHandler::class,
435 435
             ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
436
-            function (ExceptionEvent $event) {
436
+            function(ExceptionEvent $event) {
437 437
                 Craft::debug(
438 438
                     'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION',
439 439
                     __METHOD__
@@ -476,16 +476,16 @@  discard block
 block discarded – undo
476 476
     protected function handleElementUriChange(Element $element)
477 477
     {
478 478
         $uris = $this->getAllElementUris($element);
479
-        if (!empty($this->oldElementUris[$element->id])) {
480
-            $oldElementUris = $this->oldElementUris[$element->id];
479
+        if (!empty($this->oldElementUris[ $element->id ])) {
480
+            $oldElementUris = $this->oldElementUris[ $element->id ];
481 481
             foreach ($uris as $siteId => $newUri) {
482
-                if (!empty($oldElementUris[$siteId])) {
483
-                    $oldUri = $oldElementUris[$siteId];
482
+                if (!empty($oldElementUris[ $siteId ])) {
483
+                    $oldUri = $oldElementUris[ $siteId ];
484 484
                     Craft::debug(
485 485
                         Craft::t(
486 486
                             'retour',
487 487
                             'Comparing old: {oldUri} to new: {newUri}',
488
-                            ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)]
488
+                            [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ]
489 489
                         ),
490 490
                         __METHOD__
491 491
                     );
@@ -520,12 +520,12 @@  discard block
 block discarded – undo
520 520
      */
521 521
     protected function getAllElementUris(Element $element): array
522 522
     {
523
-        $uris = [];
523
+        $uris = [ ];
524 524
         $sites = Craft::$app->getSites()->getAllSites();
525 525
         foreach ($sites as $site) {
526 526
             $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id);
527 527
             if ($uri !== null) {
528
-                $uris[$site->id] = $uri;
528
+                $uris[ $site->id ] = $uri;
529 529
             }
530 530
         }
531 531
 
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
             Craft::t(
534 534
                 'retour',
535 535
                 'Getting Element URIs: {uris}',
536
-                ['uris' => print_r($uris, true)]
536
+                [ 'uris' => print_r($uris, true) ]
537 537
             ),
538 538
             __METHOD__
539 539
         );
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
             [
598 598
                 'key' => 'retour-redirect-caches',
599 599
                 'label' => Craft::t('retour', 'Retour redirect caches'),
600
-                'action' => [self::$plugin->redirects, 'invalidateCaches'],
600
+                'action' => [ self::$plugin->redirects, 'invalidateCaches' ],
601 601
             ],
602 602
         ];
603 603
     }
Please login to merge, or discard this patch.
src/controllers/FileController.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.