@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | /** |
58 | 58 | * @var array The URIs for the element before it was saved |
59 | 59 | */ |
60 | - public $oldElementUris = []; |
|
60 | + public $oldElementUris = [ ]; |
|
61 | 61 | |
62 | 62 | // Public Methods |
63 | 63 | // ========================================================================= |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | { |
70 | 70 | // Stash the old URLs by element id, and do so only once, |
71 | 71 | // in case we are called more than once per request |
72 | - if (empty($this->oldElementUris[$element->id])) { |
|
73 | - $this->oldElementUris[$element->id] = $this->getAllElementUris($element); |
|
72 | + if (empty($this->oldElementUris[ $element->id ])) { |
|
73 | + $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -80,16 +80,16 @@ discard block |
||
80 | 80 | public function handleElementUriChange(Element $element) |
81 | 81 | { |
82 | 82 | $uris = $this->getAllElementUris($element); |
83 | - if (!empty($this->oldElementUris[$element->id])) { |
|
84 | - $oldElementUris = $this->oldElementUris[$element->id]; |
|
83 | + if (!empty($this->oldElementUris[ $element->id ])) { |
|
84 | + $oldElementUris = $this->oldElementUris[ $element->id ]; |
|
85 | 85 | foreach ($uris as $siteId => $newUri) { |
86 | - if (!empty($oldElementUris[$siteId])) { |
|
87 | - $oldUri = $oldElementUris[$siteId]; |
|
86 | + if (!empty($oldElementUris[ $siteId ])) { |
|
87 | + $oldUri = $oldElementUris[ $siteId ]; |
|
88 | 88 | Craft::debug( |
89 | 89 | Craft::t( |
90 | 90 | 'retour', |
91 | 91 | 'Comparing old: {oldUri} to new: {newUri}', |
92 | - ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)] |
|
92 | + [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ] |
|
93 | 93 | ), |
94 | 94 | __METHOD__ |
95 | 95 | ); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | if (Retour::$settings->uriChangeRedirectSrcMatch === 'fullurl') { |
110 | 110 | try { |
111 | 111 | if ($redirectSiteId !== null) { |
112 | - $redirectSiteId = (int)$redirectSiteId; |
|
112 | + $redirectSiteId = (int) $redirectSiteId; |
|
113 | 113 | } |
114 | 114 | $oldUri = \craft\helpers\UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId); |
115 | 115 | $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId); |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | 'siteId' => $redirectSiteId, |
128 | 128 | ]; |
129 | 129 | // Trigger a 'beforeSaveEntryRedirect' event |
130 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
130 | + $isNew = (int) $redirectConfig[ 'id' ] === 0; |
|
131 | 131 | $event = new RedirectEvent([ |
132 | 132 | 'isNew' => $isNew, |
133 | - 'legacyUrl' => $redirectConfig['redirectSrcUrl'], |
|
134 | - 'destinationUrl' => $redirectConfig['redirectDestUrl'], |
|
135 | - 'matchType' => $redirectConfig['redirectSrcMatch'], |
|
136 | - 'redirectType' => $redirectConfig['redirectHttpCode'], |
|
137 | - 'siteId' => $redirectConfig['siteId'], |
|
133 | + 'legacyUrl' => $redirectConfig[ 'redirectSrcUrl' ], |
|
134 | + 'destinationUrl' => $redirectConfig[ 'redirectDestUrl' ], |
|
135 | + 'matchType' => $redirectConfig[ 'redirectSrcMatch' ], |
|
136 | + 'redirectType' => $redirectConfig[ 'redirectHttpCode' ], |
|
137 | + 'siteId' => $redirectConfig[ 'siteId' ], |
|
138 | 138 | ]); |
139 | 139 | $this->trigger(self::EVENT_BEFORE_SAVE_ENTRY_REDIRECT, $event); |
140 | 140 | if (!$event->isValid) { |
@@ -156,13 +156,13 @@ discard block |
||
156 | 156 | */ |
157 | 157 | protected function getAllElementUris(Element $element): array |
158 | 158 | { |
159 | - $uris = []; |
|
159 | + $uris = [ ]; |
|
160 | 160 | if (!Retour::$craft32 || !ElementHelper::isDraftOrRevision($element)) { |
161 | 161 | $sites = Craft::$app->getSites()->getAllSites(); |
162 | 162 | foreach ($sites as $site) { |
163 | 163 | $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id); |
164 | 164 | if ($uri !== null) { |
165 | - $uris[$site->id] = $uri; |
|
165 | + $uris[ $site->id ] = $uri; |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | Craft::t( |
172 | 172 | 'retour', |
173 | 173 | 'Getting Element URIs: {uris}', |
174 | - ['uris' => print_r($uris, true)] |
|
174 | + [ 'uris' => print_r($uris, true) ] |
|
175 | 175 | ), |
176 | 176 | __METHOD__ |
177 | 177 | ); |