@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | // Static Methods |
29 | 29 | // ========================================================================= |
30 | 30 | |
31 | - public static function renderStringTemplate(string $templateString, array $params = []): string |
|
31 | + public static function renderStringTemplate(string $templateString, array $params = [ ]): string |
|
32 | 32 | { |
33 | 33 | try { |
34 | 34 | $html = Seomatic::$view->renderString($templateString, $params); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $html = Craft::t( |
37 | 37 | 'seomatic', |
38 | 38 | 'Error rendering template string -> {error}', |
39 | - ['error' => $e->getMessage()] |
|
39 | + [ 'error' => $e->getMessage() ] |
|
40 | 40 | ); |
41 | 41 | Craft::error($html, __METHOD__); |
42 | 42 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return string |
54 | 54 | */ |
55 | - public static function renderPluginTemplate(string $templatePath, array $params = []): string |
|
55 | + public static function renderPluginTemplate(string $templatePath, array $params = [ ]): string |
|
56 | 56 | { |
57 | 57 | $templateRendered = false; |
58 | 58 | // Stash the old template mode, and set it AdminCP template mode |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $htmlText = Craft::t( |
72 | 72 | 'seomatic', |
73 | 73 | 'Error rendering `{template}` -> {error}', |
74 | - ['template' => $templatePath, 'error' => $e->getMessage()] |
|
74 | + [ 'template' => $templatePath, 'error' => $e->getMessage() ] |
|
75 | 75 | ); |
76 | 76 | Craft::error($htmlText, __METHOD__); |
77 | 77 | $templateRendered = false; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $htmlText = Craft::t( |
93 | 93 | 'seomatic', |
94 | 94 | 'Error rendering `{template}` -> {error}', |
95 | - ['template' => $templatePath, 'error' => $e->getMessage()] |
|
95 | + [ 'template' => $templatePath, 'error' => $e->getMessage() ] |
|
96 | 96 | ); |
97 | 97 | Craft::error($htmlText, __METHOD__); |
98 | 98 | $templateRendered = false; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | // Iterate through all of the matrix blocks |
80 | 80 | $tags = $tagQuery->all(); |
81 | 81 | foreach ($tags as $tag) { |
82 | - $result .= $tag->title.", "; |
|
82 | + $result .= $tag->title . ", "; |
|
83 | 83 | } |
84 | 84 | $result = rtrim($result, ", "); |
85 | 85 | |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | } |
109 | 109 | // Find any text fields inside of the matrix block |
110 | 110 | if ($matrixBlockTypeModel) { |
111 | - $fieldClasses = FieldHelper::FIELD_CLASSES[FieldHelper::TEXT_FIELD_CLASS_KEY]; |
|
111 | + $fieldClasses = FieldHelper::FIELD_CLASSES[ FieldHelper::TEXT_FIELD_CLASS_KEY ]; |
|
112 | 112 | $fields = $matrixBlockTypeModel->getFields(); |
113 | 113 | |
114 | 114 | foreach ($fields as $field) { |
115 | 115 | foreach ($fieldClasses as $fieldClassKey) { |
116 | 116 | if ($field instanceof $fieldClassKey) { |
117 | 117 | if ($field->handle == $fieldHandle || empty($fieldHandle)) { |
118 | - $result .= self::extractTextFromField($block[$field->handle]).' '; |
|
118 | + $result .= self::extractTextFromField($block[ $field->handle ]) . ' '; |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | } |
@@ -237,13 +237,13 @@ discard block |
||
237 | 237 | protected static function stopWordsForLanguage(string $language) |
238 | 238 | { |
239 | 239 | $stopWords = null; |
240 | - if (!empty(self::LANGUAGE_MAP[$language])) { |
|
241 | - $language = self::LANGUAGE_MAP[$language]; |
|
240 | + if (!empty(self::LANGUAGE_MAP[ $language ])) { |
|
241 | + $language = self::LANGUAGE_MAP[ $language ]; |
|
242 | 242 | } else { |
243 | 243 | $language = 'English'; |
244 | 244 | } |
245 | 245 | |
246 | - $className = 'PhpScience\\TextRank\\Tool\\StopWords\\'.ucfirst($language); |
|
246 | + $className = 'PhpScience\\TextRank\\Tool\\StopWords\\' . ucfirst($language); |
|
247 | 247 | if (class_exists($className)) { |
248 | 248 | $stopWords = new $className; |
249 | 249 | } |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | // Now try our own internal config |
49 | 49 | $path = self::getConfigFilePath('@nystudio107/seomatic', $filePath); |
50 | 50 | if (!file_exists($path)) { |
51 | - return []; |
|
51 | + return [ ]; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | 55 | if (!is_array($config = @include $path)) { |
56 | - return []; |
|
56 | + return [ ]; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // If it's not a multi-environment config, return the whole thing |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | |
64 | 64 | // If no environment was specified, just look in the '*' array |
65 | 65 | if (Seomatic::$settings->environment === null) { |
66 | - return $config['*']; |
|
66 | + return $config[ '*' ]; |
|
67 | 67 | } |
68 | 68 | |
69 | - $mergedConfig = []; |
|
69 | + $mergedConfig = [ ]; |
|
70 | 70 | foreach ($config as $env => $envConfig) { |
71 | 71 | if ($env === '*' || StringHelper::contains(Seomatic::$settings->environment, $env)) { |
72 | 72 | $mergedConfig = ArrayHelper::merge($mergedConfig, $envConfig); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function getMergedConfigFromFiles(array $filePaths): array |
87 | 87 | { |
88 | - $mergedConfig = []; |
|
88 | + $mergedConfig = [ ]; |
|
89 | 89 | foreach ($filePaths as $filePath) { |
90 | 90 | $mergedConfig = ArrayHelper::merge($mergedConfig, self::getConfigFromFile($filePath)); |
91 | 91 | } |
@@ -67,8 +67,8 @@ |
||
67 | 67 | { |
68 | 68 | $url = ''; |
69 | 69 | $config = array_merge( |
70 | - self::$transforms['base'], |
|
71 | - self::$transforms[$transformName] ?? self::$transforms['base'] |
|
70 | + self::$transforms[ 'base' ], |
|
71 | + self::$transforms[ $transformName ] ?? self::$transforms[ 'base' ] |
|
72 | 72 | ); |
73 | 73 | $transform = new AssetTransform($config); |
74 | 74 | if (is_int($asset)) { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | case self::CONFIG_DEPENDENCY: |
54 | 54 | foreach ($keys as $key) { |
55 | 55 | // If any value is in the $config[$key] it validates |
56 | - if (!empty($config[$key])) { |
|
56 | + if (!empty($config[ $key ])) { |
|
57 | 57 | $validates = true; |
58 | 58 | } |
59 | 59 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | case self::SITE_DEPENDENCY: |
63 | 63 | foreach ($keys as $key) { |
64 | 64 | // If any value is in the $site[$key] it validates |
65 | - if (!empty($site[$key])) { |
|
65 | + if (!empty($site[ $key ])) { |
|
66 | 66 | $validates = true; |
67 | 67 | } |
68 | 68 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | case self::META_DEPENDENCY: |
72 | 72 | foreach ($keys as $key) { |
73 | 73 | // If any value is in the $meta[$key] it validates |
74 | - if (!empty($meta[$key])) { |
|
74 | + if (!empty($meta[ $key ])) { |
|
75 | 75 | $validates = true; |
76 | 76 | } |
77 | 77 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $array = self::changeKey($array, 'type', '@type'); |
90 | 90 | if ($depth > 1) { |
91 | 91 | foreach (self::IGNORE_ATTRIBUTES as $attribute) { |
92 | - unset($array[$attribute]); |
|
92 | + unset($array[ $attribute ]); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | MetaValueHelper::parseArray($array); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | return $array; |
113 | 113 | } |
114 | 114 | $keys = array_keys($array); |
115 | - $keys[array_search($oldKey, $keys)] = $newKey; |
|
115 | + $keys[ array_search($oldKey, $keys) ] = $newKey; |
|
116 | 116 | |
117 | 117 | return array_combine($keys, $array); |
118 | 118 | } |
@@ -77,15 +77,15 @@ discard block |
||
77 | 77 | FieldLayout $layout, |
78 | 78 | bool $keysOnly = true |
79 | 79 | ): array { |
80 | - $foundFields = []; |
|
81 | - if (!empty(self::FIELD_CLASSES[$fieldClassKey])) { |
|
82 | - $fieldClasses = self::FIELD_CLASSES[$fieldClassKey]; |
|
80 | + $foundFields = [ ]; |
|
81 | + if (!empty(self::FIELD_CLASSES[ $fieldClassKey ])) { |
|
82 | + $fieldClasses = self::FIELD_CLASSES[ $fieldClassKey ]; |
|
83 | 83 | $fields = $layout->getFields(); |
84 | 84 | /** @var $field BaseField */ |
85 | 85 | foreach ($fields as $field) { |
86 | 86 | foreach ($fieldClasses as $fieldClassKey) { |
87 | 87 | if ($field instanceof $fieldClassKey) { |
88 | - $foundFields[$field->handle] = $field->name; |
|
88 | + $foundFields[ $field->handle ] = $field->name; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public static function fieldsOfTypeFromAssetVolumes(string $fieldClassKey, bool $keysOnly = true): array |
148 | 148 | { |
149 | - $foundFields = []; |
|
149 | + $foundFields = [ ]; |
|
150 | 150 | $volumes = Craft::$app->getVolumes()->getAllVolumes(); |
151 | 151 | foreach ($volumes as $volume) { |
152 | 152 | /** @var Volume $volume */ |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public static function fieldsOfTypeFromGlobals(string $fieldClassKey, bool $keysOnly = true): array |
179 | 179 | { |
180 | - $foundFields = []; |
|
180 | + $foundFields = [ ]; |
|
181 | 181 | $globals = Craft::$app->getGlobals()->getAllSets(); |
182 | 182 | foreach ($globals as $global) { |
183 | 183 | $layout = $global->getFieldLayout(); |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | // Prefix the keys with the global set name |
187 | 187 | $prefix = $global->handle; |
188 | 188 | $fields = array_combine( |
189 | - array_map(function ($key) use ($prefix) { |
|
190 | - return $prefix.'.'.$key; |
|
189 | + array_map(function($key) use ($prefix) { |
|
190 | + return $prefix . '.' . $key; |
|
191 | 191 | }, array_keys($fields)), |
192 | 192 | $fields |
193 | 193 | ); |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | string $fieldClassKey, |
220 | 220 | bool $keysOnly = true |
221 | 221 | ): array { |
222 | - $foundFields = []; |
|
223 | - $layouts = []; |
|
222 | + $foundFields = [ ]; |
|
223 | + $layouts = [ ]; |
|
224 | 224 | // Get the layouts |
225 | 225 | switch ($sourceBundleType) { |
226 | 226 | case MetaBundles::GLOBAL_META_BUNDLE: |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | case MetaBundles::SECTION_META_BUNDLE: |
230 | 230 | $entryTypes = Craft::$app->getSections()->getSectionByHandle($sourceHandle)->getEntryTypes(); |
231 | 231 | foreach ($entryTypes as $entryType) { |
232 | - $layouts[] = Craft::$app->getFields()->getLayoutById($entryType->fieldLayoutId); |
|
232 | + $layouts[ ] = Craft::$app->getFields()->getLayoutById($entryType->fieldLayoutId); |
|
233 | 233 | } |
234 | 234 | break; |
235 | 235 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $layoutId = null; |
241 | 241 | } |
242 | 242 | if ($layoutId) { |
243 | - $layouts[] = Craft::$app->getFields()->getLayoutById($layoutId); |
|
243 | + $layouts[ ] = Craft::$app->getFields()->getLayoutById($layoutId); |
|
244 | 244 | } |
245 | 245 | break; |
246 | 246 | // @TODO: handle commerce products |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public static function matrixFieldsOfType(MatrixBlock $matrixBlock, string $fieldType, bool $keysOnly = true): array |
269 | 269 | { |
270 | - $foundFields = []; |
|
270 | + $foundFields = [ ]; |
|
271 | 271 | |
272 | 272 | try { |
273 | 273 | $matrixBlockTypeModel = $matrixBlock->getType(); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | /** @var $field BaseField */ |
280 | 280 | foreach ($fields as $field) { |
281 | 281 | if ($field instanceof $fieldType) { |
282 | - $foundFields[$field->handle] = $field->name; |
|
282 | + $foundFields[ $field->handle ] = $field->name; |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | foreach ($metaArray as $key => $value) { |
84 | 84 | if ($value != null) { |
85 | - $metaArray[$key] = self::parseString($value); |
|
85 | + $metaArray[ $key ] = self::parseString($value); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | $metaArray = array_filter($metaArray); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | if ($reflector) { |
139 | 139 | $matchedElementType = strtolower($reflector->getShortName()); |
140 | - self::$templateObjectVars[$matchedElementType] = $element; |
|
140 | + self::$templateObjectVars[ $matchedElementType ] = $element; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $metaValue = Craft::t( |
182 | 182 | 'seomatic', |
183 | 183 | 'Error rendering `{template}` -> {error}', |
184 | - ['template' => $metaValue, 'error' => $e->getMessage()] |
|
184 | + [ 'template' => $metaValue, 'error' => $e->getMessage() ] |
|
185 | 185 | ); |
186 | 186 | Craft::error($metaValue, __METHOD__); |
187 | 187 | // Restore the template mode |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | int $siteId = null, |
204 | 204 | bool $asArray = false |
205 | 205 | ): array { |
206 | - $result = []; |
|
206 | + $result = [ ]; |
|
207 | 207 | |
208 | 208 | // Load the meta containers and parse our globals |
209 | 209 | Seomatic::$plugin->metaContainers->previewMetaContainers($uri, $siteId, true); |
@@ -211,17 +211,17 @@ discard block |
||
211 | 211 | // Iterate through the desired $containerKeys |
212 | 212 | foreach ($containerKeys as $containerKey) { |
213 | 213 | if ($asArray) { |
214 | - $result[$containerKey] = Seomatic::$plugin->metaContainers->renderContainersArrayByType( |
|
214 | + $result[ $containerKey ] = Seomatic::$plugin->metaContainers->renderContainersArrayByType( |
|
215 | 215 | $containerKey |
216 | 216 | ); |
217 | 217 | } else { |
218 | - $result[$containerKey] = Seomatic::$plugin->metaContainers->renderContainersByType( |
|
218 | + $result[ $containerKey ] = Seomatic::$plugin->metaContainers->renderContainersByType( |
|
219 | 219 | $containerKey |
220 | 220 | ); |
221 | 221 | } |
222 | 222 | } |
223 | 223 | // use "pretty" output in debug mode |
224 | - Craft::$app->response->formatters[Response::FORMAT_JSON] = [ |
|
224 | + Craft::$app->response->formatters[ Response::FORMAT_JSON ] = [ |
|
225 | 225 | 'class' => 'yii\web\JsonResponseFormatter', |
226 | 226 | 'prettyPrint' => YII_DEBUG, |
227 | 227 | ]; |