@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | foreach ($config as $propName => $propValue) { |
| 38 | 38 | if (!property_exists($class, $propName)) { |
| 39 | - unset($config[$propName]); |
|
| 39 | + unset($config[ $propName ]); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * @inheritdoc |
| 49 | 49 | */ |
| 50 | - public function __construct(array $config = []) |
|
| 50 | + public function __construct(array $config = [ ]) |
|
| 51 | 51 | { |
| 52 | 52 | // Unset any deprecated properties |
| 53 | 53 | self::cleanProperties(static::class, $config); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | if (!empty($string)) { |
| 45 | 45 | $string = strip_tags($string); |
| 46 | - $result = (string)Stringy::create($string)->truncate($length, $substring); |
|
| 46 | + $result = (string) Stringy::create($string)->truncate($length, $substring); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | return $result; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | if (!empty($string)) { |
| 69 | 69 | $string = strip_tags($string); |
| 70 | - $result = (string)Stringy::create($string)->safeTruncate($length, $substring); |
|
| 70 | + $result = (string) Stringy::create($string)->safeTruncate($length, $substring); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | return $result; |
@@ -78,8 +78,8 @@ |
||
| 78 | 78 | $rules = array_merge( |
| 79 | 79 | $rules, |
| 80 | 80 | [ |
| 81 | - ['numberOfDays', 'integer', 'min' => 1], |
|
| 82 | - ['numberOfDays', 'default', 'value' => 30], |
|
| 81 | + [ 'numberOfDays', 'integer', 'min' => 1 ], |
|
| 82 | + [ 'numberOfDays', 'default', 'value' => 30 ], |
|
| 83 | 83 | ] |
| 84 | 84 | ); |
| 85 | 85 | return $rules; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | // Protected Properties |
| 40 | 40 | // ========================================================================= |
| 41 | 41 | |
| 42 | - protected $allowAnonymous = []; |
|
| 42 | + protected $allowAnonymous = [ ]; |
|
| 43 | 43 | |
| 44 | 44 | // Public Methods |
| 45 | 45 | // ========================================================================= |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function actionPluginSettings($settings = null): Response |
| 56 | 56 | { |
| 57 | - $variables = []; |
|
| 57 | + $variables = [ ]; |
|
| 58 | 58 | PermissionHelper::controllerPermissionCheck('retour:settings'); |
| 59 | 59 | if ($settings === null) { |
| 60 | 60 | $settings = Retour::$settings; |
@@ -69,16 +69,16 @@ discard block |
||
| 69 | 69 | } catch (InvalidConfigException $e) { |
| 70 | 70 | Craft::error($e->getMessage(), __METHOD__); |
| 71 | 71 | } |
| 72 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 72 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 73 | 73 | '@nystudio107/retour/assetbundles/retour/dist', |
| 74 | 74 | true |
| 75 | 75 | ); |
| 76 | 76 | // Basic variables |
| 77 | - $variables['fullPageForm'] = true; |
|
| 78 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 79 | - $variables['pluginName'] = $pluginName; |
|
| 80 | - $variables['title'] = $templateTitle; |
|
| 81 | - $variables['crumbs'] = [ |
|
| 77 | + $variables[ 'fullPageForm' ] = true; |
|
| 78 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 79 | + $variables[ 'pluginName' ] = $pluginName; |
|
| 80 | + $variables[ 'title' ] = $templateTitle; |
|
| 81 | + $variables[ 'crumbs' ] = [ |
|
| 82 | 82 | [ |
| 83 | 83 | 'label' => $pluginName, |
| 84 | 84 | 'url' => UrlHelper::cpUrl('retour'), |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | 'url' => UrlHelper::cpUrl('retour/settings'), |
| 89 | 89 | ], |
| 90 | 90 | ]; |
| 91 | - $variables['docTitle'] = "{$pluginName} - {$templateTitle}"; |
|
| 92 | - $variables['selectedSubnavItem'] = 'settings'; |
|
| 93 | - $variables['settings'] = $settings; |
|
| 91 | + $variables[ 'docTitle' ] = "{$pluginName} - {$templateTitle}"; |
|
| 92 | + $variables[ 'selectedSubnavItem' ] = 'settings'; |
|
| 93 | + $variables[ 'settings' ] = $settings; |
|
| 94 | 94 | |
| 95 | 95 | // Render the template |
| 96 | 96 | return $this->renderTemplate('retour/settings', $variables); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | PermissionHelper::controllerPermissionCheck('retour:settings'); |
| 111 | 111 | $this->requirePostRequest(); |
| 112 | 112 | $pluginHandle = Craft::$app->getRequest()->getRequiredBodyParam('pluginHandle'); |
| 113 | - $settings = Craft::$app->getRequest()->getBodyParam('settings', []); |
|
| 113 | + $settings = Craft::$app->getRequest()->getBodyParam('settings', [ ]); |
|
| 114 | 114 | $plugin = Craft::$app->getPlugins()->getPlugin($pluginHandle); |
| 115 | 115 | |
| 116 | 116 | if ($plugin === null) { |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | // Make sure there is a leading / |
| 62 | - $value = '/'.ltrim($value, '/'); |
|
| 62 | + $value = '/' . ltrim($value, '/'); |
|
| 63 | 63 | $model->$attribute = $value; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -66,13 +66,13 @@ |
||
| 66 | 66 | */ |
| 67 | 67 | public function actionTrim(): int |
| 68 | 68 | { |
| 69 | - echo Craft::t('retour', 'Trimming statistics').PHP_EOL; |
|
| 69 | + echo Craft::t('retour', 'Trimming statistics') . PHP_EOL; |
|
| 70 | 70 | $affectedRows = Retour::$plugin->statistics->trimStatistics($this->limit); |
| 71 | 71 | echo Craft::t( |
| 72 | 72 | 'retour', |
| 73 | 73 | 'Trimmed {rows} from retour_stats table', |
| 74 | - ['rows' => $affectedRows] |
|
| 75 | - ).PHP_EOL; |
|
| 74 | + [ 'rows' => $affectedRows ] |
|
| 75 | + ) . PHP_EOL; |
|
| 76 | 76 | |
| 77 | 77 | return 0; |
| 78 | 78 | } |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | if ($legacyModule === null) { |
| 65 | 65 | return ''; |
| 66 | 66 | } |
| 67 | - $lines = []; |
|
| 67 | + $lines = [ ]; |
|
| 68 | 68 | if ($async) { |
| 69 | - $lines[] = "<link rel=\"preload\" href=\"{$legacyModule}\" as=\"style\" onload=\"this.onload=null;this.rel='stylesheet'\" />"; |
|
| 70 | - $lines[] = "<noscript><link rel=\"stylesheet\" href=\"{$legacyModule}\"></noscript>"; |
|
| 69 | + $lines[ ] = "<link rel=\"preload\" href=\"{$legacyModule}\" as=\"style\" onload=\"this.onload=null;this.rel='stylesheet'\" />"; |
|
| 70 | + $lines[ ] = "<noscript><link rel=\"stylesheet\" href=\"{$legacyModule}\"></noscript>"; |
|
| 71 | 71 | } else { |
| 72 | - $lines[] = "<link rel=\"stylesheet\" href=\"{$legacyModule}\" />"; |
|
| 72 | + $lines[ ] = "<link rel=\"stylesheet\" href=\"{$legacyModule}\" />"; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return implode("\r\n", $lines); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | $result = self::getFile($path); |
| 86 | 86 | if ($result) { |
| 87 | - $result = "<style>\r\n".$result."</style>\r\n"; |
|
| 87 | + $result = "<style>\r\n" . $result . "</style>\r\n"; |
|
| 88 | 88 | return $result; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | return ''; |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | - $lines = []; |
|
| 130 | + $lines = [ ]; |
|
| 131 | 131 | if ($async) { |
| 132 | - $lines[] = "<script type=\"module\" src=\"{$modernModule}\"></script>"; |
|
| 133 | - $lines[] = "<script nomodule src=\"{$legacyModule}\"></script>"; |
|
| 132 | + $lines[ ] = "<script type=\"module\" src=\"{$modernModule}\"></script>"; |
|
| 133 | + $lines[ ] = "<script nomodule src=\"{$legacyModule}\"></script>"; |
|
| 134 | 134 | } else { |
| 135 | - $lines[] = "<script src=\"{$legacyModule}\"></script>"; |
|
| 135 | + $lines[ ] = "<script src=\"{$legacyModule}\"></script>"; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | return implode("\r\n", $lines); |
@@ -183,8 +183,8 @@ discard block |
||
| 183 | 183 | $module = self::getModuleEntry($config, $moduleName, $type, $soft); |
| 184 | 184 | if ($module !== null) { |
| 185 | 185 | $prefix = self::$isHot |
| 186 | - ? $config['devServer']['publicPath'] |
|
| 187 | - : $config['server']['publicPath']; |
|
| 186 | + ? $config[ 'devServer' ][ 'publicPath' ] |
|
| 187 | + : $config[ 'server' ][ 'publicPath' ]; |
|
| 188 | 188 | // If the module isn't a full URL, prefix it |
| 189 | 189 | if (!UrlHelper::isAbsoluteUrl($module)) { |
| 190 | 190 | $module = self::combinePaths($prefix, $module); |
@@ -225,16 +225,16 @@ discard block |
||
| 225 | 225 | $manifest = self::getManifestFile($config, $type); |
| 226 | 226 | if ($manifest !== null) { |
| 227 | 227 | // Make sure it exists in the manifest |
| 228 | - if (empty($manifest[$moduleName])) { |
|
| 228 | + if (empty($manifest[ $moduleName ])) { |
|
| 229 | 229 | self::reportError(Craft::t( |
| 230 | 230 | 'retour', |
| 231 | 231 | 'Module does not exist in the manifest: {moduleName}', |
| 232 | - ['moduleName' => $moduleName] |
|
| 232 | + [ 'moduleName' => $moduleName ] |
|
| 233 | 233 | ), $soft); |
| 234 | 234 | |
| 235 | 235 | return null; |
| 236 | 236 | } |
| 237 | - $module = $manifest[$moduleName]; |
|
| 237 | + $module = $manifest[ $moduleName ]; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | return $module; |
@@ -254,14 +254,14 @@ discard block |
||
| 254 | 254 | $manifest = null; |
| 255 | 255 | // Determine whether we should use the devServer for HMR or not |
| 256 | 256 | $devMode = Craft::$app->getConfig()->getGeneral()->devMode; |
| 257 | - self::$isHot = ($devMode && $config['useDevServer']); |
|
| 257 | + self::$isHot = ($devMode && $config[ 'useDevServer' ]); |
|
| 258 | 258 | // Try to get the manifest |
| 259 | 259 | while ($manifest === null) { |
| 260 | 260 | $manifestPath = self::$isHot |
| 261 | - ? $config['devServer']['manifestPath'] |
|
| 262 | - : $config['server']['manifestPath']; |
|
| 261 | + ? $config[ 'devServer' ][ 'manifestPath' ] |
|
| 262 | + : $config[ 'server' ][ 'manifestPath' ]; |
|
| 263 | 263 | // Normalize the path |
| 264 | - $path = self::combinePaths($manifestPath, $config['manifest'][$type]); |
|
| 264 | + $path = self::combinePaths($manifestPath, $config[ 'manifest' ][ $type ]); |
|
| 265 | 265 | $manifest = self::getJsonFile($path); |
| 266 | 266 | // If the manifest isn't found, and it was hot, fall back on non-hot |
| 267 | 267 | if ($manifest === null) { |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | self::reportError(Craft::t( |
| 270 | 270 | 'retour', |
| 271 | 271 | 'Manifest file not found at: {manifestPath}', |
| 272 | - ['manifestPath' => $manifestPath] |
|
| 272 | + [ 'manifestPath' => $manifestPath ] |
|
| 273 | 273 | ), true); |
| 274 | 274 | if (self::$isHot) { |
| 275 | 275 | // Try again, but not with home module replacement |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | if ($path !== null) { |
| 314 | 314 | $path = self::combinePaths( |
| 315 | - $config['localFiles']['basePath'], |
|
| 315 | + $config[ 'localFiles' ][ 'basePath' ], |
|
| 316 | 316 | $path |
| 317 | 317 | ); |
| 318 | 318 | |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | */ |
| 332 | 332 | protected static function getJsonFile(string $path) |
| 333 | 333 | { |
| 334 | - return self::getFileFromUri($path, [self::class, 'jsonFileDecode']); |
|
| 334 | + return self::getFileFromUri($path, [ self::class, 'jsonFileDecode' ]); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -385,14 +385,14 @@ discard block |
||
| 385 | 385 | protected static function getFileContents(string $path, callable $callback = null) |
| 386 | 386 | { |
| 387 | 387 | // Return the memoized manifest if it exists |
| 388 | - if (!empty(self::$files[$path])) { |
|
| 389 | - return self::$files[$path]; |
|
| 388 | + if (!empty(self::$files[ $path ])) { |
|
| 389 | + return self::$files[ $path ]; |
|
| 390 | 390 | } |
| 391 | 391 | // Create the dependency tags |
| 392 | 392 | $dependency = new TagDependency([ |
| 393 | 393 | 'tags' => [ |
| 394 | 394 | self::CACHE_TAG, |
| 395 | - self::CACHE_TAG.$path, |
|
| 395 | + self::CACHE_TAG . $path, |
|
| 396 | 396 | ], |
| 397 | 397 | ]); |
| 398 | 398 | // Set the cache duration based on devMode |
@@ -402,8 +402,8 @@ discard block |
||
| 402 | 402 | // Get the result from the cache, or parse the file |
| 403 | 403 | $cache = Craft::$app->getCache(); |
| 404 | 404 | $file = $cache->getOrSet( |
| 405 | - self::CACHE_KEY.$path, |
|
| 406 | - function () use ($path, $callback) { |
|
| 405 | + self::CACHE_KEY . $path, |
|
| 406 | + function() use ($path, $callback) { |
|
| 407 | 407 | $result = null; |
| 408 | 408 | $contents = @file_get_contents($path); |
| 409 | 409 | if ($contents) { |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | $cacheDuration, |
| 419 | 419 | $dependency |
| 420 | 420 | ); |
| 421 | - self::$files[$path] = $file; |
|
| 421 | + self::$files[ $path ] = $file; |
|
| 422 | 422 | |
| 423 | 423 | return $file; |
| 424 | 424 | } |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | protected static function combinePaths(string ...$paths): string |
| 434 | 434 | { |
| 435 | 435 | $last_key = \count($paths) - 1; |
| 436 | - array_walk($paths, function (&$val, $key) use ($last_key) { |
|
| 436 | + array_walk($paths, function(&$val, $key) use ($last_key) { |
|
| 437 | 437 | switch ($key) { |
| 438 | 438 | case 0: |
| 439 | 439 | $val = rtrim($val, '/ '); |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | $last = array_pop($paths); |
| 452 | 452 | $paths = array_filter($paths); |
| 453 | 453 | array_unshift($paths, $first); |
| 454 | - $paths[] = $last; |
|
| 454 | + $paths[ ] = $last; |
|
| 455 | 455 | |
| 456 | 456 | return implode('/', $paths); |
| 457 | 457 | } |
@@ -47,11 +47,11 @@ |
||
| 47 | 47 | $bundle->sourcePath, |
| 48 | 48 | true |
| 49 | 49 | ); |
| 50 | - self::$config['server']['manifestPath'] = Craft::getAlias($bundle->sourcePath); |
|
| 51 | - self::$config['server']['publicPath'] = $baseAssetsUrl; |
|
| 50 | + self::$config[ 'server' ][ 'manifestPath' ] = Craft::getAlias($bundle->sourcePath); |
|
| 51 | + self::$config[ 'server' ][ 'publicPath' ] = $baseAssetsUrl; |
|
| 52 | 52 | $useDevServer = getenv('NYS_PLUGIN_DEVSERVER'); |
| 53 | 53 | if ($useDevServer !== false) { |
| 54 | - self::$config['useDevServer'] = (bool)$useDevServer; |
|
| 54 | + self::$config[ 'useDevServer' ] = (bool) $useDevServer; |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -96,18 +96,18 @@ discard block |
||
| 96 | 96 | public function rules() |
| 97 | 97 | { |
| 98 | 98 | return [ |
| 99 | - ['id', 'integer'], |
|
| 100 | - ['siteId', 'integer'], |
|
| 101 | - ['siteId', 'default', 'value' => null], |
|
| 102 | - ['associatedElementId', 'default', 'value' => 0], |
|
| 103 | - ['associatedElementId', 'integer'], |
|
| 104 | - ['enabled', 'boolean'], |
|
| 105 | - ['redirectSrcMatch', 'default', 'value' => 'pathonly'], |
|
| 106 | - ['redirectSrcMatch', DbStringValidator::class, 'max' => 32], |
|
| 107 | - ['redirectSrcMatch', 'string'], |
|
| 108 | - ['redirectMatchType', 'default', 'value' => 'exactmatch'], |
|
| 109 | - ['redirectMatchType', DbStringValidator::class, 'max' => 32], |
|
| 110 | - ['redirectMatchType', 'string'], |
|
| 99 | + [ 'id', 'integer' ], |
|
| 100 | + [ 'siteId', 'integer' ], |
|
| 101 | + [ 'siteId', 'default', 'value' => null ], |
|
| 102 | + [ 'associatedElementId', 'default', 'value' => 0 ], |
|
| 103 | + [ 'associatedElementId', 'integer' ], |
|
| 104 | + [ 'enabled', 'boolean' ], |
|
| 105 | + [ 'redirectSrcMatch', 'default', 'value' => 'pathonly' ], |
|
| 106 | + [ 'redirectSrcMatch', DbStringValidator::class, 'max' => 32 ], |
|
| 107 | + [ 'redirectSrcMatch', 'string' ], |
|
| 108 | + [ 'redirectMatchType', 'default', 'value' => 'exactmatch' ], |
|
| 109 | + [ 'redirectMatchType', DbStringValidator::class, 'max' => 32 ], |
|
| 110 | + [ 'redirectMatchType', 'string' ], |
|
| 111 | 111 | [ |
| 112 | 112 | [ |
| 113 | 113 | 'redirectSrcUrl', |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | 'default', |
| 118 | 118 | 'value' => '' |
| 119 | 119 | ], |
| 120 | - ['redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl'], |
|
| 120 | + [ 'redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl' ], |
|
| 121 | 121 | [ |
| 122 | 122 | [ |
| 123 | 123 | 'redirectSrcUrl', |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | ], |
| 145 | 145 | 'string' |
| 146 | 146 | ], |
| 147 | - ['redirectHttpCode', 'integer'], |
|
| 148 | - ['redirectHttpCode', 'default', 'value' => 301], |
|
| 149 | - ['hitCount', 'default', 'value' => 0], |
|
| 150 | - ['hitCount', 'integer'], |
|
| 151 | - ['hitLastTime', 'safe'], |
|
| 147 | + [ 'redirectHttpCode', 'integer' ], |
|
| 148 | + [ 'redirectHttpCode', 'default', 'value' => 301 ], |
|
| 149 | + [ 'hitCount', 'default', 'value' => 0 ], |
|
| 150 | + [ 'hitCount', 'integer' ], |
|
| 151 | + [ 'hitLastTime', 'safe' ], |
|
| 152 | 152 | ]; |
| 153 | 153 | } |
| 154 | 154 | |