@@ -78,7 +78,7 @@ discard block  | 
                                                    ||
| 78 | 78 | // Protected Properties  | 
                                                        
| 79 | 79 | // =========================================================================  | 
                                                        
| 80 | 80 | |
| 81 | - protected $allowAnonymous = [];  | 
                                                        |
| 81 | + protected $allowAnonymous = [ ];  | 
                                                        |
| 82 | 82 | |
| 83 | 83 | // Public Methods  | 
                                                        
| 84 | 84 | // =========================================================================  | 
                                                        
@@ -148,7 +148,7 @@ discard block  | 
                                                    ||
| 148 | 148 | */  | 
                                                        
| 149 | 149 | public function actionImportCsv(string $siteHandle = null): Response  | 
                                                        
| 150 | 150 |      { | 
                                                        
| 151 | - $variables = [];  | 
                                                        |
| 151 | + $variables = [ ];  | 
                                                        |
| 152 | 152 |          PermissionHelper::controllerPermissionCheck('retour:redirects'); | 
                                                        
| 153 | 153 | // If your CSV document was created or is read on a Macintosh computer,  | 
                                                        
| 154 | 154 | // add the following lines before using the library to help PHP detect line ending in Mac OS X  | 
                                                        
@@ -166,38 +166,38 @@ discard block  | 
                                                    ||
| 166 | 166 |          } catch (InvalidConfigException $e) { | 
                                                        
| 167 | 167 | Craft::error($e->getMessage(), __METHOD__);  | 
                                                        
| 168 | 168 | }  | 
                                                        
| 169 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(  | 
                                                        |
| 169 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl(  | 
                                                        |
| 170 | 170 | '@nystudio107/retour/assetbundles/retour/dist',  | 
                                                        
| 171 | 171 | true  | 
                                                        
| 172 | 172 | );  | 
                                                        
| 173 | 173 | // Enabled sites  | 
                                                        
| 174 | 174 | MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables);  | 
                                                        
| 175 | - $variables['controllerHandle'] = 'file';  | 
                                                        |
| 175 | + $variables[ 'controllerHandle' ] = 'file';  | 
                                                        |
| 176 | 176 | |
| 177 | 177 | // Basic variables  | 
                                                        
| 178 | - $variables['fullPageForm'] = true;  | 
                                                        |
| 179 | - $variables['docsUrl'] = self::DOCUMENTATION_URL;  | 
                                                        |
| 180 | - $variables['pluginName'] = $pluginName;  | 
                                                        |
| 181 | - $variables['title'] = $templateTitle;  | 
                                                        |
| 182 | - $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';  | 
                                                        |
| 183 | - $variables['crumbs'] = [  | 
                                                        |
| 178 | + $variables[ 'fullPageForm' ] = true;  | 
                                                        |
| 179 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL;  | 
                                                        |
| 180 | + $variables[ 'pluginName' ] = $pluginName;  | 
                                                        |
| 181 | + $variables[ 'title' ] = $templateTitle;  | 
                                                        |
| 182 | + $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : '';  | 
                                                        |
| 183 | + $variables[ 'crumbs' ] = [  | 
                                                        |
| 184 | 184 | [  | 
                                                        
| 185 | 185 | 'label' => $pluginName,  | 
                                                        
| 186 | 186 |                  'url' => UrlHelper::cpUrl('retour'), | 
                                                        
| 187 | 187 | ],  | 
                                                        
| 188 | 188 | [  | 
                                                        
| 189 | 189 | 'label' => 'Redirects',  | 
                                                        
| 190 | -                'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri), | 
                                                        |
| 190 | +                'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri), | 
                                                        |
| 191 | 191 | ],  | 
                                                        
| 192 | 192 | ];  | 
                                                        
| 193 | -        $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}"; | 
                                                        |
| 194 | - $variables['selectedSubnavItem'] = 'redirects';  | 
                                                        |
| 193 | +        $variables[ 'docTitle' ] = "{$pluginName} - Redirects - {$templateTitle}"; | 
                                                        |
| 194 | + $variables[ 'selectedSubnavItem' ] = 'redirects';  | 
                                                        |
| 195 | 195 | |
| 196 | 196 | // The CSV file  | 
                                                        
| 197 | 197 |          $file = UploadedFile::getInstanceByName('file'); | 
                                                        
| 198 | 198 |          if ($file !== null) { | 
                                                        
| 199 | 199 | $filename = uniqid($file->name, true);  | 
                                                        
| 200 | - $filePath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$filename;  | 
                                                        |
| 200 | + $filePath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $filename;  | 
                                                        |
| 201 | 201 | $file->saveAs($filePath, false);  | 
                                                        
| 202 | 202 | // Also save the file to the cache as a backup way to access it  | 
                                                        
| 203 | 203 | $cache = Craft::$app->getCache();  | 
                                                        
@@ -213,8 +213,8 @@ discard block  | 
                                                    ||
| 213 | 213 | $csv = Reader::createFromPath($file->tempName);  | 
                                                        
| 214 | 214 | $headers = $csv->fetchOne(0);  | 
                                                        
| 215 | 215 | Craft::info(print_r($headers, true), __METHOD__);  | 
                                                        
| 216 | - $variables['headers'] = $headers;  | 
                                                        |
| 217 | - $variables['filename'] = $filePath;  | 
                                                        |
| 216 | + $variables[ 'headers' ] = $headers;  | 
                                                        |
| 217 | + $variables[ 'filename' ] = $filePath;  | 
                                                        |
| 218 | 218 | }  | 
                                                        
| 219 | 219 | |
| 220 | 220 | // Render the template  | 
                                                        
@@ -260,7 +260,7 @@ discard block  | 
                                                    ||
| 260 | 260 | }  | 
                                                        
| 261 | 261 | // Query the db table  | 
                                                        
| 262 | 262 | $data = (new Query())  | 
                                                        
| 263 | - ->from([$table])  | 
                                                        |
| 263 | + ->from([ $table ])  | 
                                                        |
| 264 | 264 | ->select(array_keys($columns))  | 
                                                        
| 265 | 265 |              ->orderBy('hitCount DESC') | 
                                                        
| 266 | 266 | ->all();  | 
                                                        
@@ -268,7 +268,7 @@ discard block  | 
                                                    ||
| 268 | 268 | $csv = Writer::createFromFileObject(new \SplTempFileObject());  | 
                                                        
| 269 | 269 | $csv->insertOne(array_values($columns));  | 
                                                        
| 270 | 270 | $csv->insertAll($data);  | 
                                                        
| 271 | - $csv->output($filename.'.csv');  | 
                                                        |
| 271 | + $csv->output($filename . '.csv');  | 
                                                        |
| 272 | 272 | exit(0);  | 
                                                        
| 273 | 273 | }  | 
                                                        
| 274 | 274 | |
@@ -281,16 +281,16 @@ discard block  | 
                                                    ||
| 281 | 281 |      { | 
                                                        
| 282 | 282 | $csv->setOffset(1);  | 
                                                        
| 283 | 283 | $columns = ArrayHelper::filterEmptyStringsFromArray($columns);  | 
                                                        
| 284 | -        $csv->each(function ($row) use ($headers, $columns) { | 
                                                        |
| 284 | +        $csv->each(function($row) use ($headers, $columns) { | 
                                                        |
| 285 | 285 | $redirectConfig = [  | 
                                                        
| 286 | 286 | 'id' => 0,  | 
                                                        
| 287 | 287 | ];  | 
                                                        
| 288 | 288 | $index = 0;  | 
                                                        
| 289 | 289 |              foreach (self::IMPORT_REDIRECTS_CSV_FIELDS as $importField) { | 
                                                        
| 290 | -                if (isset($columns[$index], $headers[$columns[$index]])) { | 
                                                        |
| 291 | - $redirectConfig[$importField] = empty($row[$headers[$columns[$index]]])  | 
                                                        |
| 290 | +                if (isset($columns[ $index ], $headers[ $columns[ $index ] ])) { | 
                                                        |
| 291 | + $redirectConfig[ $importField ] = empty($row[ $headers[ $columns[ $index ] ] ])  | 
                                                        |
| 292 | 292 | ? null  | 
                                                        
| 293 | - : $row[$headers[$columns[$index]]];  | 
                                                        |
| 293 | + : $row[ $headers[ $columns[ $index ] ] ];  | 
                                                        |
| 294 | 294 | }  | 
                                                        
| 295 | 295 | $index++;  | 
                                                        
| 296 | 296 | }  | 
                                                        
@@ -320,10 +320,10 @@ discard block  | 
                                                    ||
| 320 | 320 | ];  | 
                                                        
| 321 | 321 | $index = 0;  | 
                                                        
| 322 | 322 |              foreach (self::IMPORT_REDIRECTS_CSV_FIELDS as $importField) { | 
                                                        
| 323 | -                if (isset($columns[$index], $headers[$columns[$index]])) { | 
                                                        |
| 324 | - $redirectConfig[$importField] = empty($row[$headers[$columns[$index]]])  | 
                                                        |
| 323 | +                if (isset($columns[ $index ], $headers[ $columns[ $index ] ])) { | 
                                                        |
| 324 | + $redirectConfig[ $importField ] = empty($row[ $headers[ $columns[ $index ] ] ])  | 
                                                        |
| 325 | 325 | ? null  | 
                                                        
| 326 | - : $row[$headers[$columns[$index]]];  | 
                                                        |
| 326 | + : $row[ $headers[ $columns[ $index ] ] ];  | 
                                                        |
| 327 | 327 | }  | 
                                                        
| 328 | 328 | $index++;  | 
                                                        
| 329 | 329 | }  |