@@ -84,12 +84,12 @@ discard block |
||
| 84 | 84 | public function rules() |
| 85 | 85 | { |
| 86 | 86 | return [ |
| 87 | - ['id', 'integer'], |
|
| 88 | - ['locale', DbStringValidator::class, 'max' => 12], |
|
| 89 | - ['locale', 'string'], |
|
| 90 | - ['locale', 'default', 'value' => ''], |
|
| 91 | - ['associatedElementId', 'default', 'value' => 0], |
|
| 92 | - ['associatedElementId', 'integer'], |
|
| 87 | + [ 'id', 'integer' ], |
|
| 88 | + [ 'locale', DbStringValidator::class, 'max' => 12 ], |
|
| 89 | + [ 'locale', 'string' ], |
|
| 90 | + [ 'locale', 'default', 'value' => '' ], |
|
| 91 | + [ 'associatedElementId', 'default', 'value' => 0 ], |
|
| 92 | + [ 'associatedElementId', 'integer' ], |
|
| 93 | 93 | [ |
| 94 | 94 | [ |
| 95 | 95 | 'redirectSrcUrl', |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | 'default', |
| 101 | 101 | 'value' => '' |
| 102 | 102 | ], |
| 103 | - ['redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl'], |
|
| 103 | + [ 'redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl' ], |
|
| 104 | 104 | [ |
| 105 | 105 | [ |
| 106 | 106 | 'redirectSrcUrl', |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | ], |
| 129 | 129 | 'string' |
| 130 | 130 | ], |
| 131 | - ['redirectHttpCode', 'integer'], |
|
| 132 | - ['redirectHttpCode', 'default', 'value' => 301], |
|
| 133 | - ['hitCount', 'default', 'value' => 0], |
|
| 134 | - ['hitCount', 'integer'], |
|
| 135 | - ['hitLastTime', 'safe'], |
|
| 131 | + [ 'redirectHttpCode', 'integer' ], |
|
| 132 | + [ 'redirectHttpCode', 'default', 'value' => 301 ], |
|
| 133 | + [ 'hitCount', 'default', 'value' => 0 ], |
|
| 134 | + [ 'hitCount', 'integer' ], |
|
| 135 | + [ 'hitLastTime', 'safe' ], |
|
| 136 | 136 | ]; |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -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); |
@@ -84,12 +84,12 @@ discard block |
||
| 84 | 84 | public function rules() |
| 85 | 85 | { |
| 86 | 86 | return [ |
| 87 | - ['id', 'integer'], |
|
| 88 | - ['locale', DbStringValidator::class, 'max' => 12], |
|
| 89 | - ['locale', 'string'], |
|
| 90 | - ['locale', 'default', 'value' => ''], |
|
| 91 | - ['associatedElementId', 'integer'], |
|
| 92 | - ['redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl', 'parse' => false], |
|
| 87 | + [ 'id', 'integer' ], |
|
| 88 | + [ 'locale', DbStringValidator::class, 'max' => 12 ], |
|
| 89 | + [ 'locale', 'string' ], |
|
| 90 | + [ 'locale', 'default', 'value' => '' ], |
|
| 91 | + [ 'associatedElementId', 'integer' ], |
|
| 92 | + [ 'redirectSrcUrlParsed', ParsedUriValidator::class, 'source' => 'redirectSrcUrl', 'parse' => false ], |
|
| 93 | 93 | [ |
| 94 | 94 | [ |
| 95 | 95 | 'redirectSrcUrl', |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | 'default', |
| 128 | 128 | 'value' => '' |
| 129 | 129 | ], |
| 130 | - ['redirectHttpCode', 'integer'], |
|
| 131 | - ['redirectHttpCode', 'default', 'value' => 301], |
|
| 132 | - ['hitCount', 'integer'], |
|
| 133 | - ['hitCount', 'default', 'value' => 0], |
|
| 134 | - ['hitLastTime', 'safe'], |
|
| 130 | + [ 'redirectHttpCode', 'integer' ], |
|
| 131 | + [ 'redirectHttpCode', 'default', 'value' => 301 ], |
|
| 132 | + [ 'hitCount', 'integer' ], |
|
| 133 | + [ 'hitCount', 'default', 'value' => 0 ], |
|
| 134 | + [ 'hitLastTime', 'safe' ], |
|
| 135 | 135 | ]; |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | public function rules() |
| 76 | 76 | { |
| 77 | 77 | return [ |
| 78 | - ['pluginName', 'string'], |
|
| 79 | - ['pluginName', 'default', 'value' => 'Retour'], |
|
| 78 | + [ 'pluginName', 'string' ], |
|
| 79 | + [ 'pluginName', 'default', 'value' => 'Retour' ], |
|
| 80 | 80 | [ |
| 81 | 81 | [ |
| 82 | 82 | 'createUriChangeRedirects', |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | ], |
| 86 | 86 | 'boolean' |
| 87 | 87 | ], |
| 88 | - ['staticRedirectDisplayLimit', 'integer', 'min' => 1], |
|
| 89 | - ['staticRedirectDisplayLimit', 'default', 'value' => 100], |
|
| 90 | - ['dynamicRedirectDisplayLimit', 'integer', 'min' => 1], |
|
| 91 | - ['dynamicRedirectDisplayLimit', 'default', 'value' => 100], |
|
| 92 | - ['statsStoredLimit', 'integer', 'min' => 1], |
|
| 93 | - ['statsStoredLimit', 'default', 'value' => 1000], |
|
| 94 | - ['statsDisplayLimit', 'integer', 'min' => 1], |
|
| 95 | - ['statsDisplayLimit', 'default', 'value' => 1000], |
|
| 88 | + [ 'staticRedirectDisplayLimit', 'integer', 'min' => 1 ], |
|
| 89 | + [ 'staticRedirectDisplayLimit', 'default', 'value' => 100 ], |
|
| 90 | + [ 'dynamicRedirectDisplayLimit', 'integer', 'min' => 1 ], |
|
| 91 | + [ 'dynamicRedirectDisplayLimit', 'default', 'value' => 100 ], |
|
| 92 | + [ 'statsStoredLimit', 'integer', 'min' => 1 ], |
|
| 93 | + [ 'statsStoredLimit', 'default', 'value' => 1000 ], |
|
| 94 | + [ 'statsDisplayLimit', 'integer', 'min' => 1 ], |
|
| 95 | + [ 'statsDisplayLimit', 'default', 'value' => 1000 ], |
|
| 96 | 96 | ]; |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -62,18 +62,18 @@ |
||
| 62 | 62 | public function rules() |
| 63 | 63 | { |
| 64 | 64 | return [ |
| 65 | - ['id', 'integer'], |
|
| 66 | - ['redirectSrcUrl', DbStringValidator::class, 'max' => 255], |
|
| 67 | - ['redirectSrcUrl', 'string'], |
|
| 68 | - ['redirectSrcUrl', 'default', 'value' => ''], |
|
| 69 | - ['referrerUrl', DbStringValidator::class, 'max' => 2000], |
|
| 70 | - ['referrerUrl', 'string'], |
|
| 71 | - ['referrerUrl', 'default', 'value' => ''], |
|
| 72 | - ['hitCount', 'integer'], |
|
| 73 | - ['hitCount', 'default', 'value' => 0], |
|
| 74 | - ['hitLastTime', 'safe'], |
|
| 75 | - ['handledByRetour', 'integer', 'min' => 0, 'max' => 1], |
|
| 76 | - ['handledByRetour', 'default', 'value' => 0], |
|
| 65 | + [ 'id', 'integer' ], |
|
| 66 | + [ 'redirectSrcUrl', DbStringValidator::class, 'max' => 255 ], |
|
| 67 | + [ 'redirectSrcUrl', 'string' ], |
|
| 68 | + [ 'redirectSrcUrl', 'default', 'value' => '' ], |
|
| 69 | + [ 'referrerUrl', DbStringValidator::class, 'max' => 2000 ], |
|
| 70 | + [ 'referrerUrl', 'string' ], |
|
| 71 | + [ 'referrerUrl', 'default', 'value' => '' ], |
|
| 72 | + [ 'hitCount', 'integer' ], |
|
| 73 | + [ 'hitCount', 'default', 'value' => 0 ], |
|
| 74 | + [ 'hitLastTime', 'safe' ], |
|
| 75 | + [ 'handledByRetour', 'integer', 'min' => 0, 'max' => 1 ], |
|
| 76 | + [ 'handledByRetour', 'default', 'value' => 0 ], |
|
| 77 | 77 | ]; |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -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; |
@@ -42,43 +42,43 @@ discard block |
||
| 42 | 42 | $sites = Craft::$app->getSites(); |
| 43 | 43 | if (Craft::$app->getIsMultiSite()) { |
| 44 | 44 | // Set defaults based on the section settings |
| 45 | - $variables['enabledSiteIds'] = []; |
|
| 46 | - $variables['siteIds'] = []; |
|
| 45 | + $variables[ 'enabledSiteIds' ] = [ ]; |
|
| 46 | + $variables[ 'siteIds' ] = [ ]; |
|
| 47 | 47 | |
| 48 | 48 | /** @var Site $site */ |
| 49 | 49 | foreach ($sites->getEditableSiteIds() as $editableSiteId) { |
| 50 | - $variables['enabledSiteIds'][] = $editableSiteId; |
|
| 51 | - $variables['siteIds'][] = $editableSiteId; |
|
| 50 | + $variables[ 'enabledSiteIds' ][ ] = $editableSiteId; |
|
| 51 | + $variables[ 'siteIds' ][ ] = $editableSiteId; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Make sure the $siteId they are trying to edit is in our array of editable sites |
| 55 | - if (!\in_array($siteId, $variables['enabledSiteIds'], false)) { |
|
| 56 | - if (!empty($variables['enabledSiteIds'])) { |
|
| 57 | - $siteId = reset($variables['enabledSiteIds']); |
|
| 55 | + if (!\in_array($siteId, $variables[ 'enabledSiteIds' ], false)) { |
|
| 56 | + if (!empty($variables[ 'enabledSiteIds' ])) { |
|
| 57 | + $siteId = reset($variables[ 'enabledSiteIds' ]); |
|
| 58 | 58 | } else { |
| 59 | - self::requirePermission('editSite:'.$siteId); |
|
| 59 | + self::requirePermission('editSite:' . $siteId); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | // Set the currentSiteId and currentSiteHandle |
| 64 | - $variables['currentSiteId'] = empty($siteId) ? Craft::$app->getSites()->currentSite->id : $siteId; |
|
| 65 | - $variables['currentSiteHandle'] = empty($siteHandle) |
|
| 64 | + $variables[ 'currentSiteId' ] = empty($siteId) ? Craft::$app->getSites()->currentSite->id : $siteId; |
|
| 65 | + $variables[ 'currentSiteHandle' ] = empty($siteHandle) |
|
| 66 | 66 | ? Craft::$app->getSites()->currentSite->handle |
| 67 | 67 | : $siteHandle; |
| 68 | 68 | |
| 69 | 69 | // Page title |
| 70 | - $variables['showSites'] = ( |
|
| 70 | + $variables[ 'showSites' ] = ( |
|
| 71 | 71 | Craft::$app->getIsMultiSite() && |
| 72 | - \count($variables['enabledSiteIds']) |
|
| 72 | + \count($variables[ 'enabledSiteIds' ]) |
|
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | - if ($variables['showSites']) { |
|
| 76 | - $variables['sitesMenuLabel'] = Craft::t( |
|
| 75 | + if ($variables[ 'showSites' ]) { |
|
| 76 | + $variables[ 'sitesMenuLabel' ] = Craft::t( |
|
| 77 | 77 | 'site', |
| 78 | - $sites->getSiteById((int)$variables['currentSiteId'])->name |
|
| 78 | + $sites->getSiteById((int) $variables[ 'currentSiteId' ])->name |
|
| 79 | 79 | ); |
| 80 | 80 | } else { |
| 81 | - $variables['sitesMenuLabel'] = ''; |
|
| 81 | + $variables[ 'sitesMenuLabel' ] = ''; |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | if ($siteHandle !== null) { |
| 97 | 97 | $site = Craft::$app->getSites()->getSiteByHandle($siteHandle); |
| 98 | 98 | if (!$site) { |
| 99 | - throw new NotFoundHttpException('Invalid site handle: '.$siteHandle); |
|
| 99 | + throw new NotFoundHttpException('Invalid site handle: ' . $siteHandle); |
|
| 100 | 100 | } |
| 101 | 101 | $siteId = $site->id; |
| 102 | 102 | } else { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | Craft::t( |
| 106 | 106 | 'retour', |
| 107 | 107 | '{name} plugin loaded', |
| 108 | - ['name' => $this->name] |
|
| 108 | + [ 'name' => $this->name ] |
|
| 109 | 109 | ), |
| 110 | 110 | __METHOD__ |
| 111 | 111 | ); |
@@ -125,24 +125,24 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function getCpNavItem() |
| 127 | 127 | { |
| 128 | - $subNavs = []; |
|
| 128 | + $subNavs = [ ]; |
|
| 129 | 129 | $navItem = parent::getCpNavItem(); |
| 130 | 130 | $currentUser = Craft::$app->getUser()->getIdentity(); |
| 131 | 131 | // Only show sub-navs the user has permission to view |
| 132 | 132 | if ($currentUser->can('retour:dashboard')) { |
| 133 | - $subNavs['dashboard'] = [ |
|
| 133 | + $subNavs[ 'dashboard' ] = [ |
|
| 134 | 134 | 'label' => 'Dashboard', |
| 135 | 135 | 'url' => 'retour/dashboard', |
| 136 | 136 | ]; |
| 137 | 137 | } |
| 138 | 138 | if ($currentUser->can('retour:redirects')) { |
| 139 | - $subNavs['redirects'] = [ |
|
| 139 | + $subNavs[ 'redirects' ] = [ |
|
| 140 | 140 | 'label' => 'Redirects', |
| 141 | 141 | 'url' => 'retour/redirects', |
| 142 | 142 | ]; |
| 143 | 143 | } |
| 144 | 144 | if ($currentUser->can('retour:settings')) { |
| 145 | - $subNavs['settings'] = [ |
|
| 145 | + $subNavs[ 'settings' ] = [ |
|
| 146 | 146 | 'label' => 'Settings', |
| 147 | 147 | 'url' => 'retour/settings', |
| 148 | 148 | ]; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | Event::on( |
| 202 | 202 | Plugins::class, |
| 203 | 203 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 204 | - function (PluginEvent $event) { |
|
| 204 | + function(PluginEvent $event) { |
|
| 205 | 205 | if ($event->plugin === $this) { |
| 206 | 206 | // Invalidate our caches after we've been installed |
| 207 | 207 | $this->clearAllCaches(); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | Event::on( |
| 229 | 229 | CraftVariable::class, |
| 230 | 230 | CraftVariable::EVENT_INIT, |
| 231 | - function (Event $event) { |
|
| 231 | + function(Event $event) { |
|
| 232 | 232 | /** @var CraftVariable $variable */ |
| 233 | 233 | $variable = $event->sender; |
| 234 | 234 | $variable->set('retour', RetourVariable::class); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | Event::on( |
| 239 | 239 | Plugins::class, |
| 240 | 240 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 241 | - function () { |
|
| 241 | + function() { |
|
| 242 | 242 | // Install these only after all other plugins have loaded |
| 243 | 243 | $request = Craft::$app->getRequest(); |
| 244 | 244 | // Only respond to non-console site requests |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | Event::on( |
| 263 | 263 | UrlManager::class, |
| 264 | 264 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 265 | - function (RegisterUrlRulesEvent $event) { |
|
| 265 | + function(RegisterUrlRulesEvent $event) { |
|
| 266 | 266 | Craft::debug( |
| 267 | 267 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 268 | 268 | __METHOD__ |
@@ -285,15 +285,15 @@ discard block |
||
| 285 | 285 | Event::on( |
| 286 | 286 | Dashboard::class, |
| 287 | 287 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
| 288 | - function (RegisterComponentTypesEvent $event) { |
|
| 289 | - $event->types[] = RetourWidget::class; |
|
| 288 | + function(RegisterComponentTypesEvent $event) { |
|
| 289 | + $event->types[ ] = RetourWidget::class; |
|
| 290 | 290 | } |
| 291 | 291 | ); |
| 292 | 292 | // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES |
| 293 | 293 | Event::on( |
| 294 | 294 | UrlManager::class, |
| 295 | 295 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 296 | - function (RegisterUrlRulesEvent $event) { |
|
| 296 | + function(RegisterUrlRulesEvent $event) { |
|
| 297 | 297 | Craft::debug( |
| 298 | 298 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 299 | 299 | __METHOD__ |
@@ -309,20 +309,20 @@ discard block |
||
| 309 | 309 | Event::on( |
| 310 | 310 | UserPermissions::class, |
| 311 | 311 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 312 | - function (RegisterUserPermissionsEvent $event) { |
|
| 312 | + function(RegisterUserPermissionsEvent $event) { |
|
| 313 | 313 | Craft::debug( |
| 314 | 314 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 315 | 315 | __METHOD__ |
| 316 | 316 | ); |
| 317 | 317 | // Register our custom permissions |
| 318 | - $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions(); |
|
| 318 | + $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions(); |
|
| 319 | 319 | } |
| 320 | 320 | ); |
| 321 | 321 | // Handler: ClearCaches::EVENT_REGISTER_CACHE_OPTIONS |
| 322 | 322 | Event::on( |
| 323 | 323 | ClearCaches::class, |
| 324 | 324 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 325 | - function (RegisterCacheOptionsEvent $event) { |
|
| 325 | + function(RegisterCacheOptionsEvent $event) { |
|
| 326 | 326 | Craft::debug( |
| 327 | 327 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
| 328 | 328 | __METHOD__ |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | Event::on( |
| 348 | 348 | ErrorHandler::class, |
| 349 | 349 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
| 350 | - function (ExceptionEvent $event) { |
|
| 350 | + function(ExceptionEvent $event) { |
|
| 351 | 351 | Craft::debug( |
| 352 | 352 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
| 353 | 353 | __METHOD__ |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | [ |
| 443 | 443 | 'key' => 'retour-redirect-caches', |
| 444 | 444 | 'label' => Craft::t('retour', 'Retour redirect caches'), |
| 445 | - 'action' => [self::$plugin->redirects, 'invalidateCaches'], |
|
| 445 | + 'action' => [ self::$plugin->redirects, 'invalidateCaches' ], |
|
| 446 | 446 | ], |
| 447 | 447 | ]; |
| 448 | 448 | } |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | { |
| 47 | 47 | // Make sure there is a leading / |
| 48 | 48 | $value = $model->$attribute; |
| 49 | - $value = '/'.ltrim($value, '/'); |
|
| 49 | + $value = '/' . ltrim($value, '/'); |
|
| 50 | 50 | $model->$attribute = $value; |
| 51 | 51 | } |
| 52 | 52 | } |