@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | // Handle trailing slashes properly for generated URLs |
| 48 | 48 | $generalConfig = Craft::$app->getConfig()->getGeneral(); |
| 49 | 49 | if ($generalConfig->addTrailingSlashesToUrls && !preg_match('/\.[^\/]+$/', $url)) { |
| 50 | - $url = rtrim($url, '/') . '/'; |
|
| 50 | + $url = rtrim($url, '/').'/'; |
|
| 51 | 51 | } |
| 52 | 52 | if (!$generalConfig->addTrailingSlashesToUrls) { |
| 53 | 53 | $url = rtrim($url, '/'); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | // Handle trailing slashes properly for generated URLs |
| 125 | 125 | $generalConfig = Craft::$app->getConfig()->getGeneral(); |
| 126 | 126 | if ($generalConfig->addTrailingSlashesToUrls && !preg_match('/\.[^\/]+$/', $url)) { |
| 127 | - $url = rtrim($url, '/') . '/'; |
|
| 127 | + $url = rtrim($url, '/').'/'; |
|
| 128 | 128 | } |
| 129 | 129 | if (!$generalConfig->addTrailingSlashesToUrls) { |
| 130 | 130 | $url = rtrim($url, '/'); |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | if (filter_var($pathOrUrl, FILTER_VALIDATE_URL)) { |
| 162 | 162 | $url_parts = parse_url($pathOrUrl); |
| 163 | - $result['prefix'] = $url_parts['scheme'] . '://' . $url_parts['host']; |
|
| 163 | + $result['prefix'] = $url_parts['scheme'].'://'.$url_parts['host']; |
|
| 164 | 164 | $result['path'] = $url_parts['path'] ?? ''; |
| 165 | 165 | $result['suffix'] = ''; |
| 166 | - $result['suffix'] .= empty($url_parts['query']) ? '' : '?' . $url_parts['query']; |
|
| 167 | - $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#' . $url_parts['fragment']; |
|
| 166 | + $result['suffix'] .= empty($url_parts['query']) ? '' : '?'.$url_parts['query']; |
|
| 167 | + $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#'.$url_parts['fragment']; |
|
| 168 | 168 | } else { |
| 169 | 169 | $result['prefix'] = ''; |
| 170 | 170 | $result['path'] = $pathOrUrl; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $metaBundle->metaSitemapVars->sitemapLimit = null; |
| 119 | 119 | } |
| 120 | 120 | $totalElements = $seoElement::sitemapElementsQuery($metaBundle)->count(); |
| 121 | - if ($metaBundle->metaSitemapVars->sitemapLimit && ($totalElements > $metaBundle->metaSitemapVars->sitemapLimit)) { |
|
| 121 | + if ($metaBundle->metaSitemapVars->sitemapLimit && ($totalElements > $metaBundle->metaSitemapVars->sitemapLimit)) { |
|
| 122 | 122 | $totalElements = $metaBundle->metaSitemapVars->sitemapLimit; |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | while ($currentElement < $totalElements) { |
| 141 | 141 | $elements = $paginator->getPageResults(); |
| 142 | 142 | if (Craft::$app instanceof ConsoleApplication) { |
| 143 | - echo 'Query ' . $paginator->getCurrentPage() . '/' . $paginator->getTotalPages() |
|
| 144 | - . ' - elements: ' . $paginator->getTotalResults() |
|
| 143 | + echo 'Query '.$paginator->getCurrentPage().'/'.$paginator->getTotalPages() |
|
| 144 | + . ' - elements: '.$paginator->getTotalResults() |
|
| 145 | 145 | . PHP_EOL; |
| 146 | 146 | } |
| 147 | 147 | /** @var ElementInterface $element */ |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | $canonicalUrl = UrlHelper::absoluteUrlWithProtocol($canonicalUrl); |
| 192 | 192 | if ($url !== $canonicalUrl) { |
| 193 | - Craft::info("Excluding URL: {$url} from the sitemap because it does not match the Canonical URL: {$canonicalUrl} - " . $metaBundle->metaGlobalVars->canonicalUrl . " - " . $element->uri); |
|
| 193 | + Craft::info("Excluding URL: {$url} from the sitemap because it does not match the Canonical URL: {$canonicalUrl} - ".$metaBundle->metaGlobalVars->canonicalUrl." - ".$element->uri); |
|
| 194 | 194 | continue; |
| 195 | 195 | } |
| 196 | 196 | } |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | */ |
| 480 | 480 | protected static function assetSitemapItem(Asset $asset, MetaBundle $metaBundle, array &$lines) |
| 481 | 481 | { |
| 482 | - if ((bool)$asset->enabledForSite && $asset->getUrl() !== null) { |
|
| 482 | + if ((bool) $asset->enabledForSite && $asset->getUrl() !== null) { |
|
| 483 | 483 | switch ($asset->kind) { |
| 484 | 484 | case 'image': |
| 485 | 485 | $lines[] = '<image:image>'; |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | */ |
| 528 | 528 | protected static function assetFilesSitemapLink(Asset $asset, MetaBundle $metaBundle, array &$lines) |
| 529 | 529 | { |
| 530 | - if ((bool)$asset->enabledForSite && $asset->getUrl() !== null) { |
|
| 530 | + if ((bool) $asset->enabledForSite && $asset->getUrl() !== null) { |
|
| 531 | 531 | if (\in_array($asset->kind, SitemapTemplate::FILE_TYPES, false)) { |
| 532 | 532 | $dateUpdated = $asset->dateUpdated ?? $asset->dateCreated ?? new \DateTime; |
| 533 | 533 | $lines[] = '<url>'; |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | 'name' => 'Frontend Templates', |
| 23 | 23 | 'description' => 'Templates that are rendered on the frontend', |
| 24 | 24 | 'handle' => FrontendTemplates::FRONTENDTEMPLATES_CONTAINER, |
| 25 | - 'class' => (string)FrontendTemplateContainer::class, |
|
| 25 | + 'class' => (string) FrontendTemplateContainer::class, |
|
| 26 | 26 | 'include' => true, |
| 27 | 27 | 'data' => [ |
| 28 | 28 | FrontendTemplates::HUMANS_TXT_HANDLE => [ |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | // Get the page number of this request |
| 158 | 158 | $request = Craft::$app->getRequest(); |
| 159 | 159 | if (!$request->isConsoleRequest) { |
| 160 | - $this->paginationPage = (string)$request->pageNum; |
|
| 160 | + $this->paginationPage = (string) $request->pageNum; |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
@@ -173,10 +173,10 @@ discard block |
||
| 173 | 173 | $uniqueKey = $dependency->tags[3] ?? self::GLOBALS_CACHE_KEY; |
| 174 | 174 | $uniqueKey .= $bodyPosition; |
| 175 | 175 | $scriptData = Craft::$app->getCache()->getOrSet( |
| 176 | - self::GLOBALS_CACHE_KEY . $uniqueKey, |
|
| 177 | - function () use ($uniqueKey, $bodyPosition) { |
|
| 176 | + self::GLOBALS_CACHE_KEY.$uniqueKey, |
|
| 177 | + function() use ($uniqueKey, $bodyPosition) { |
|
| 178 | 178 | Craft::info( |
| 179 | - self::SCRIPTS_CACHE_KEY . ' cache miss: ' . $uniqueKey, |
|
| 179 | + self::SCRIPTS_CACHE_KEY.' cache miss: '.$uniqueKey, |
|
| 180 | 180 | __METHOD__ |
| 181 | 181 | ); |
| 182 | 182 | $scriptData = []; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | foreach ($scriptContainer->data as $metaScript) { |
| 189 | 189 | /** @var MetaScript $metaScript */ |
| 190 | 190 | if (!empty($metaScript->bodyTemplatePath) |
| 191 | - && ((int)$metaScript->bodyPosition === $bodyPosition)) { |
|
| 191 | + && ((int) $metaScript->bodyPosition === $bodyPosition)) { |
|
| 192 | 192 | $scriptData[] = $metaScript->renderBodyHtml(); |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -268,10 +268,10 @@ discard block |
||
| 268 | 268 | $dependency = $this->containerDependency; |
| 269 | 269 | $uniqueKey = $dependency->tags[3] ?? self::GLOBALS_CACHE_KEY; |
| 270 | 270 | list($this->metaGlobalVars, $this->metaSiteVars) = Craft::$app->getCache()->getOrSet( |
| 271 | - self::GLOBALS_CACHE_KEY . $uniqueKey, |
|
| 272 | - function () use ($uniqueKey) { |
|
| 271 | + self::GLOBALS_CACHE_KEY.$uniqueKey, |
|
| 272 | + function() use ($uniqueKey) { |
|
| 273 | 273 | Craft::info( |
| 274 | - self::GLOBALS_CACHE_KEY . ' cache miss: ' . $uniqueKey, |
|
| 274 | + self::GLOBALS_CACHE_KEY.' cache miss: '.$uniqueKey, |
|
| 275 | 275 | __METHOD__ |
| 276 | 276 | ); |
| 277 | 277 | |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | ?? 1; |
| 393 | 393 | } |
| 394 | 394 | // Handle pagination |
| 395 | - $paginationPage = 'page' . $this->paginationPage; |
|
| 395 | + $paginationPage = 'page'.$this->paginationPage; |
|
| 396 | 396 | // Get the path for the current request |
| 397 | 397 | $request = Craft::$app->getRequest(); |
| 398 | 398 | $requestPath = '/'; |
@@ -408,21 +408,21 @@ discard block |
||
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | // Get our cache key |
| 411 | - $cacheKey = $uri . $siteId . $paginationPage . $requestPath . $this->getAllowedUrlParams(); |
|
| 411 | + $cacheKey = $uri.$siteId.$paginationPage.$requestPath.$this->getAllowedUrlParams(); |
|
| 412 | 412 | // For requests with a status code of >= 400, use one cache key |
| 413 | 413 | if (!$request->isConsoleRequest) { |
| 414 | 414 | $response = Craft::$app->getResponse(); |
| 415 | 415 | if ($response->statusCode >= 400) { |
| 416 | - $cacheKey = $siteId . self::INVALID_RESPONSE_CACHE_KEY . $response->statusCode; |
|
| 416 | + $cacheKey = $siteId.self::INVALID_RESPONSE_CACHE_KEY.$response->statusCode; |
|
| 417 | 417 | } |
| 418 | 418 | } |
| 419 | 419 | // Load the meta containers |
| 420 | 420 | $dependency = new TagDependency([ |
| 421 | 421 | 'tags' => [ |
| 422 | 422 | self::GLOBAL_METACONTAINER_CACHE_TAG, |
| 423 | - self::METACONTAINER_CACHE_TAG . $metaBundleSourceId . $metaBundleSourceType . $siteId, |
|
| 424 | - self::METACONTAINER_CACHE_TAG . $uri . $siteId, |
|
| 425 | - self::METACONTAINER_CACHE_TAG . $cacheKey, |
|
| 423 | + self::METACONTAINER_CACHE_TAG.$metaBundleSourceId.$metaBundleSourceType.$siteId, |
|
| 424 | + self::METACONTAINER_CACHE_TAG.$uri.$siteId, |
|
| 425 | + self::METACONTAINER_CACHE_TAG.$cacheKey, |
|
| 426 | 426 | ], |
| 427 | 427 | ]); |
| 428 | 428 | $this->containerDependency = $dependency; |
@@ -438,10 +438,10 @@ discard block |
||
| 438 | 438 | } else { |
| 439 | 439 | $cache = Craft::$app->getCache(); |
| 440 | 440 | list($this->metaGlobalVars, $this->metaSiteVars, $this->metaSitemapVars, $this->metaContainers) = $cache->getOrSet( |
| 441 | - self::CACHE_KEY . $cacheKey, |
|
| 442 | - function () use ($uri, $siteId) { |
|
| 441 | + self::CACHE_KEY.$cacheKey, |
|
| 442 | + function() use ($uri, $siteId) { |
|
| 443 | 443 | Craft::info( |
| 444 | - 'Meta container cache miss: ' . $uri . '/' . $siteId, |
|
| 444 | + 'Meta container cache miss: '.$uri.'/'.$siteId, |
|
| 445 | 445 | __METHOD__ |
| 446 | 446 | ); |
| 447 | 447 | $this->loadGlobalMetaContainers($siteId); |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | |
| 711 | 711 | // Handle re-creating the `mainEntityOfPage` so that the model injected into the |
| 712 | 712 | // templates has the appropriate attributes |
| 713 | - $generalContainerKey = MetaJsonLdContainer::CONTAINER_TYPE . JsonLdService::GENERAL_HANDLE; |
|
| 713 | + $generalContainerKey = MetaJsonLdContainer::CONTAINER_TYPE.JsonLdService::GENERAL_HANDLE; |
|
| 714 | 714 | $generalContainer = $this->metaContainers[$generalContainerKey]; |
| 715 | 715 | if (($generalContainer !== null) && !empty($generalContainer->data['mainEntityOfPage'])) { |
| 716 | 716 | /** @var MetaJsonLd $jsonLdModel */ |
@@ -962,10 +962,10 @@ discard block |
||
| 962 | 962 | $cache = Craft::$app->getCache(); |
| 963 | 963 | TagDependency::invalidate( |
| 964 | 964 | $cache, |
| 965 | - self::METACONTAINER_CACHE_TAG . $metaBundleSourceId . $metaBundleSourceType . $siteId |
|
| 965 | + self::METACONTAINER_CACHE_TAG.$metaBundleSourceId.$metaBundleSourceType.$siteId |
|
| 966 | 966 | ); |
| 967 | 967 | Craft::info( |
| 968 | - 'Meta bundle cache cleared: ' . $metaBundleSourceId . ' / ' . $metaBundleSourceType . ' / ' . $siteId, |
|
| 968 | + 'Meta bundle cache cleared: '.$metaBundleSourceId.' / '.$metaBundleSourceType.' / '.$siteId, |
|
| 969 | 969 | __METHOD__ |
| 970 | 970 | ); |
| 971 | 971 | // Trigger an event to let other plugins/modules know we've cleared our caches |
@@ -992,9 +992,9 @@ discard block |
||
| 992 | 992 | if ($siteId === null) { |
| 993 | 993 | $siteId = Craft::$app->getSites()->currentSite->id ?? 1; |
| 994 | 994 | } |
| 995 | - TagDependency::invalidate($cache, self::METACONTAINER_CACHE_TAG . $uri . $siteId); |
|
| 995 | + TagDependency::invalidate($cache, self::METACONTAINER_CACHE_TAG.$uri.$siteId); |
|
| 996 | 996 | Craft::info( |
| 997 | - 'Meta container cache cleared: ' . $uri . ' / ' . $siteId, |
|
| 997 | + 'Meta container cache cleared: '.$uri.' / '.$siteId, |
|
| 998 | 998 | __METHOD__ |
| 999 | 999 | ); |
| 1000 | 1000 | // Trigger an event to let other plugins/modules know we've cleared our caches |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | if ($pageInfo !== null && $pageInfo->currentPage !== null) { |
| 86 | 86 | // Let the meta containers know that this page is paginated |
| 87 | - Seomatic::$plugin->metaContainers->paginationPage = (string)$pageInfo->currentPage; |
|
| 87 | + Seomatic::$plugin->metaContainers->paginationPage = (string) $pageInfo->currentPage; |
|
| 88 | 88 | // See if we should strip the query params |
| 89 | 89 | $stripQueryParams = true; |
| 90 | 90 | $pageTrigger = Craft::$app->getConfig()->getGeneral()->pageTrigger; |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | if (is_array($content)) { |
| 158 | 158 | $headerValue = ''; |
| 159 | 159 | foreach ($content as $contentVal) { |
| 160 | - $headerValue .= ($contentVal . ','); |
|
| 160 | + $headerValue .= ($contentVal.','); |
|
| 161 | 161 | } |
| 162 | 162 | $headerValue = rtrim($headerValue, ','); |
| 163 | 163 | } else { |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | if (is_array($href)) { |
| 177 | 177 | $headerValue = ''; |
| 178 | 178 | foreach ($href as $hrefVal) { |
| 179 | - $headerValue .= ('<' . $hrefVal . '>' . ','); |
|
| 179 | + $headerValue .= ('<'.$hrefVal.'>'.','); |
|
| 180 | 180 | } |
| 181 | 181 | $headerValue = rtrim($headerValue, ','); |
| 182 | 182 | } else { |
| 183 | - $headerValue = '<' . $href . '>'; |
|
| 183 | + $headerValue = '<'.$href.'>'; |
|
| 184 | 184 | } |
| 185 | 185 | $headerValue .= "; rel='canonical'"; |
| 186 | 186 | $response->headers->add('Link', $headerValue); |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | if (is_array($content)) { |
| 197 | 197 | $headerValue = ''; |
| 198 | 198 | foreach ($content as $contentVal) { |
| 199 | - $headerValue .= ($contentVal . ','); |
|
| 199 | + $headerValue .= ($contentVal.','); |
|
| 200 | 200 | } |
| 201 | 201 | $headerValue = rtrim($headerValue, ','); |
| 202 | 202 | } else { |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | if ($lastElement && $element) { |
| 383 | 383 | if ($lastElement->uri !== '__home__' && $element->uri) { |
| 384 | 384 | $path = $lastElement->uri; |
| 385 | - $segments = array_values(array_filter(explode('/', $path), function ($segment) { |
|
| 385 | + $segments = array_values(array_filter(explode('/', $path), function($segment) { |
|
| 386 | 386 | return $segment !== ''; |
| 387 | 387 | })); |
| 388 | 388 | } |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | $element = $elements->getElementByUri($url, $site->id, false); |
| 543 | 543 | } |
| 544 | 544 | if ($element !== null) { |
| 545 | - if (isset($element->enabledForSite) && !(bool)$element->enabledForSite) { |
|
| 545 | + if (isset($element->enabledForSite) && !(bool) $element->enabledForSite) { |
|
| 546 | 546 | $includeUrl = false; |
| 547 | 547 | } |
| 548 | 548 | /** @var MetaBundle $metaBundle */ |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | if (isset($value[$day][$time]) |
| 796 | 796 | && ($date = DateTimeHelper::toDateTime($value[$day][$time])) !== false |
| 797 | 797 | ) { |
| 798 | - $normalized[$day][$time] = (array)($date); |
|
| 798 | + $normalized[$day][$time] = (array) ($date); |
|
| 799 | 799 | } else { |
| 800 | 800 | $normalized[$day][$time] = null; |
| 801 | 801 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * @param MetaBundle $metaBundle |
| 176 | 176 | * @param bool $forceUpdate |
| 177 | 177 | */ |
| 178 | - public function syncBundleWithConfig(MetaBundle &$metaBundle, bool $forceUpdate = false) |
|
| 178 | + public function syncBundleWithConfig(MetaBundle & $metaBundle, bool $forceUpdate = false) |
|
| 179 | 179 | { |
| 180 | 180 | $prevMetaBundle = $metaBundle; |
| 181 | 181 | $config = []; |
@@ -304,8 +304,8 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | public function updateMetaBundle(MetaBundle $metaBundle, int $siteId) |
| 306 | 306 | { |
| 307 | - $metaBundle->sourceName = (string)$metaBundle->sourceName; |
|
| 308 | - $metaBundle->sourceTemplate = (string)$metaBundle->sourceTemplate; |
|
| 307 | + $metaBundle->sourceName = (string) $metaBundle->sourceName; |
|
| 308 | + $metaBundle->sourceTemplate = (string) $metaBundle->sourceTemplate; |
|
| 309 | 309 | // Make sure it validates |
| 310 | 310 | if ($metaBundle->validate(null, true)) { |
| 311 | 311 | // Save it out to a record |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | 'sourceSiteId' => $siteId, |
| 316 | 316 | ]; |
| 317 | 317 | if ($metaBundle->typeId !== null) { |
| 318 | - $metaBundle->typeId = (int)$metaBundle->typeId; |
|
| 318 | + $metaBundle->typeId = (int) $metaBundle->typeId; |
|
| 319 | 319 | } |
| 320 | 320 | if (!empty($metaBundle->typeId)) { |
| 321 | 321 | $params['typeId'] = $metaBundle->typeId; |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | // @TODO remove this hack that doesn't allow environment-transformed settings to be saved in a meta bundle with a proper system to address it |
| 332 | 332 | // The issue was that the containers were getting saved to the db with a hard-coded setting in them, because they'd |
| 333 | 333 | // been set that way by the environment, whereas to be changeable via the GUI, it needs to be set to {seomatic.meta.robots} |
| 334 | - $robotsTag = $metaBundle->metaContainers[MetaTagContainer::CONTAINER_TYPE . TagService::GENERAL_HANDLE]->data['robots'] ?? null; |
|
| 334 | + $robotsTag = $metaBundle->metaContainers[MetaTagContainer::CONTAINER_TYPE.TagService::GENERAL_HANDLE]->data['robots'] ?? null; |
|
| 335 | 335 | if (!empty($robotsTag)) { |
| 336 | 336 | $robotsTag->content = $robotsTag->environment['live']['content'] ?? '{seomatic.meta.robots}'; |
| 337 | 337 | } |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | $metaBundleDefaults = ArrayHelper::merge( |
| 414 | 414 | $seoElement::metaBundleConfig($sourceModel), |
| 415 | 415 | [ |
| 416 | - 'sourceTemplate' => (string)$siteSetting->template, |
|
| 416 | + 'sourceTemplate' => (string) $siteSetting->template, |
|
| 417 | 417 | 'sourceSiteId' => $siteSetting->siteId, |
| 418 | 418 | 'sourceAltSiteSettings' => $siteSettingsArray, |
| 419 | 419 | 'sourceDateUpdated' => $dateUpdated, |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | public function getMetaBundleBySourceHandle(string $sourceBundleType, string $sourceHandle, int $sourceSiteId, $typeId = null) |
| 462 | 462 | { |
| 463 | 463 | $metaBundle = null; |
| 464 | - $typeId = (int)$typeId; |
|
| 464 | + $typeId = (int) $typeId; |
|
| 465 | 465 | // See if we have the meta bundle cached |
| 466 | 466 | if (!empty($this->metaBundlesBySourceHandle[$sourceBundleType][$sourceHandle][$sourceSiteId][$typeId])) { |
| 467 | 467 | $id = $this->metaBundlesBySourceHandle[$sourceBundleType][$sourceHandle][$sourceSiteId][$typeId]; |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | /** @var Section|CategoryGroup|ProductType $sourceModel */ |
| 549 | 549 | $sourceModel = $seoElement::sourceModelFromId($sourceId); |
| 550 | 550 | if ($sourceModel !== null) { |
| 551 | - $metaBundle->sourceName = (string)$sourceModel->name; |
|
| 551 | + $metaBundle->sourceName = (string) $sourceModel->name; |
|
| 552 | 552 | $metaBundle->sourceHandle = $sourceModel->handle; |
| 553 | 553 | } |
| 554 | 554 | } |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | public function getMetaBundleBySourceId(string $sourceBundleType, int $sourceId, int $sourceSiteId, $typeId = null) |
| 589 | 589 | { |
| 590 | 590 | $metaBundle = null; |
| 591 | - $typeId = (int)$typeId; |
|
| 591 | + $typeId = (int) $typeId; |
|
| 592 | 592 | // See if we have the meta bundle cached |
| 593 | 593 | if (!empty($this->metaBundlesBySourceId[$sourceBundleType][$sourceId][$sourceSiteId][$typeId])) { |
| 594 | 594 | $id = $this->metaBundlesBySourceId[$sourceBundleType][$sourceId][$sourceSiteId][$typeId]; |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | ->from(['{{%seomatic_metabundles}}']) |
| 785 | 785 | ->where(['=', 'sourceBundleType', $seoElement::META_BUNDLE_TYPE]); |
| 786 | 786 | |
| 787 | - if ((int)$sourceSiteId !== 0) { |
|
| 787 | + if ((int) $sourceSiteId !== 0) { |
|
| 788 | 788 | $subQuery->andWhere(['sourceSiteId' => $sourceSiteId]); |
| 789 | 789 | } |
| 790 | 790 | if ($filter !== '') { |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | public function getContentMetaBundleForElement(Element $element) |
| 822 | 822 | { |
| 823 | 823 | $source = $this->getMetaSourceFromElement($element); |
| 824 | - $key = implode(".", $source) . '.' . $element->siteId; |
|
| 824 | + $key = implode(".", $source).'.'.$element->siteId; |
|
| 825 | 825 | |
| 826 | 826 | if (empty($this->elementContentMetaBundles[$key])) { |
| 827 | 827 | $this->elementContentMetaBundles[$key] = $this->getMetaBundleBySourceId($source[1], $source[0], $element->siteId, $source[4]); |
@@ -81,24 +81,24 @@ |
||
| 81 | 81 | $metaContainers = Seomatic::$plugin->metaContainers; |
| 82 | 82 | // Get our cache key |
| 83 | 83 | $asArrayKey = $asArray ? 'true' : 'false'; |
| 84 | - $cacheKey = $uri . $siteId . implode($containerKeys) . $asArrayKey . Seomatic::$environment; |
|
| 84 | + $cacheKey = $uri.$siteId.implode($containerKeys).$asArrayKey.Seomatic::$environment; |
|
| 85 | 85 | // Load the meta containers |
| 86 | 86 | $dependency = new TagDependency([ |
| 87 | 87 | 'tags' => [ |
| 88 | 88 | $metaContainers::GLOBAL_METACONTAINER_CACHE_TAG, |
| 89 | - $metaContainers::METACONTAINER_CACHE_TAG . $sourceId . $sourceBundleType . $siteId, |
|
| 90 | - $metaContainers::METACONTAINER_CACHE_TAG . $uri . $siteId, |
|
| 91 | - $metaContainers::METACONTAINER_CACHE_TAG . $cacheKey, |
|
| 89 | + $metaContainers::METACONTAINER_CACHE_TAG.$sourceId.$sourceBundleType.$siteId, |
|
| 90 | + $metaContainers::METACONTAINER_CACHE_TAG.$uri.$siteId, |
|
| 91 | + $metaContainers::METACONTAINER_CACHE_TAG.$cacheKey, |
|
| 92 | 92 | ], |
| 93 | 93 | ]); |
| 94 | 94 | |
| 95 | 95 | $cache = Craft::$app->getCache(); |
| 96 | 96 | $result = $cache->getOrSet( |
| 97 | - self::CACHE_KEY . $cacheKey, |
|
| 98 | - function () use ($uri, $siteId, $containerKeys, $asArray) { |
|
| 97 | + self::CACHE_KEY.$cacheKey, |
|
| 98 | + function() use ($uri, $siteId, $containerKeys, $asArray) { |
|
| 99 | 99 | $result = []; |
| 100 | 100 | Craft::info( |
| 101 | - 'Meta controller container cache miss: ' . $uri . '/' . $siteId, |
|
| 101 | + 'Meta controller container cache miss: '.$uri.'/'.$siteId, |
|
| 102 | 102 | __METHOD__ |
| 103 | 103 | ); |
| 104 | 104 | // Load the meta containers and parse our globals |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | $metaValue = Craft::t( |
| 295 | 295 | 'seomatic', |
| 296 | 296 | 'Error rendering `{template}` -> {error}', |
| 297 | - ['template' => $metaValue, 'error' => $e->getMessage() . ' - ' . print_r($metaValue, true)] |
|
| 297 | + ['template' => $metaValue, 'error' => $e->getMessage().' - '.print_r($metaValue, true)] |
|
| 298 | 298 | ); |
| 299 | 299 | Craft::error($metaValue, __METHOD__); |
| 300 | 300 | Craft::$app->getErrorHandler()->logException($e); |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | // Handle being passed in an object |
| 314 | 314 | if (is_object($metaValue)) { |
| 315 | 315 | if ($metaValue instanceof Markup) { |
| 316 | - return trim(html_entity_decode((string)$metaValue, ENT_NOQUOTES, 'UTF-8')); |
|
| 316 | + return trim(html_entity_decode((string) $metaValue, ENT_NOQUOTES, 'UTF-8')); |
|
| 317 | 317 | } |
| 318 | 318 | if ($metaValue instanceof Asset) { |
| 319 | 319 | /** @var Asset $metaValue */ |
@@ -65,19 +65,19 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | foreach (self::PULL_TEXT_FIELDS as $fields) { |
| 67 | 67 | $fieldName = $fields['fieldName']; |
| 68 | - $source = $bundleSettings[$fieldName . 'Source'] ?? ''; |
|
| 69 | - $sourceField = $bundleSettings[$fieldName . 'Field'] ?? ''; |
|
| 68 | + $source = $bundleSettings[$fieldName.'Source'] ?? ''; |
|
| 69 | + $sourceField = $bundleSettings[$fieldName.'Field'] ?? ''; |
|
| 70 | 70 | if (!empty($source)) { |
| 71 | 71 | $seoField = $fields['seoField']; |
| 72 | 72 | switch ($source) { |
| 73 | 73 | case 'sameAsSeo': |
| 74 | 74 | $globalsSettings[$fieldName] = |
| 75 | - '{{ seomatic.meta.' . $seoField . ' }}'; |
|
| 75 | + '{{ seomatic.meta.'.$seoField.' }}'; |
|
| 76 | 76 | break; |
| 77 | 77 | |
| 78 | 78 | case 'sameAsSiteTwitter': |
| 79 | 79 | $globalsSettings[$fieldName] = |
| 80 | - '{{ seomatic.site.' . $seoField . ' }}'; |
|
| 80 | + '{{ seomatic.site.'.$seoField.' }}'; |
|
| 81 | 81 | break; |
| 82 | 82 | |
| 83 | 83 | case 'sameAsGlobal': |
@@ -88,28 +88,28 @@ discard block |
||
| 88 | 88 | case 'fromField': |
| 89 | 89 | $globalsSettings[$fieldName] = |
| 90 | 90 | '{{ seomatic.helper.extractTextFromField(' |
| 91 | - . $objectPrefix . $elementName . $sourceField |
|
| 91 | + . $objectPrefix.$elementName.$sourceField |
|
| 92 | 92 | . ') }}'; |
| 93 | 93 | break; |
| 94 | 94 | |
| 95 | 95 | case 'fromUserField': |
| 96 | 96 | $globalsSettings[$fieldName] = |
| 97 | 97 | '{{ seomatic.helper.extractTextFromField(' |
| 98 | - . $objectPrefix . $elementName . 'author.' . $sourceField |
|
| 98 | + . $objectPrefix.$elementName.'author.'.$sourceField |
|
| 99 | 99 | . ') }}'; |
| 100 | 100 | break; |
| 101 | 101 | |
| 102 | 102 | case 'summaryFromField': |
| 103 | 103 | $globalsSettings[$fieldName] = |
| 104 | 104 | '{{ seomatic.helper.extractSummary(seomatic.helper.extractTextFromField(' |
| 105 | - . $objectPrefix . $elementName . $sourceField |
|
| 105 | + . $objectPrefix.$elementName.$sourceField |
|
| 106 | 106 | . ')) }}'; |
| 107 | 107 | break; |
| 108 | 108 | |
| 109 | 109 | case 'keywordsFromField': |
| 110 | 110 | $globalsSettings[$fieldName] = |
| 111 | 111 | '{{ seomatic.helper.extractKeywords(seomatic.helper.extractTextFromField(' |
| 112 | - . $objectPrefix . $elementName . $sourceField |
|
| 112 | + . $objectPrefix.$elementName.$sourceField |
|
| 113 | 113 | . ')) }}'; |
| 114 | 114 | break; |
| 115 | 115 | |
@@ -140,25 +140,25 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | foreach (self::PULL_ASSET_FIELDS as $fields) { |
| 142 | 142 | $fieldName = $fields['fieldName']; |
| 143 | - $fieldNameWidth = $fields['fieldName'] . 'Width'; |
|
| 144 | - $fieldNameHeight = $fields['fieldName'] . 'Height'; |
|
| 145 | - $source = $bundleSettings[$fieldName . 'Source'] ?? ''; |
|
| 146 | - $ids = $bundleSettings[$fieldName . 'Ids'] ?? []; |
|
| 147 | - $sourceField = $bundleSettings[$fieldName . 'Field'] ?? ''; |
|
| 143 | + $fieldNameWidth = $fields['fieldName'].'Width'; |
|
| 144 | + $fieldNameHeight = $fields['fieldName'].'Height'; |
|
| 145 | + $source = $bundleSettings[$fieldName.'Source'] ?? ''; |
|
| 146 | + $ids = $bundleSettings[$fieldName.'Ids'] ?? []; |
|
| 147 | + $sourceField = $bundleSettings[$fieldName.'Field'] ?? ''; |
|
| 148 | 148 | if (!empty($source)) { |
| 149 | - $transformImage = $bundleSettings[$fieldName . 'Transform'] ?? true; |
|
| 149 | + $transformImage = $bundleSettings[$fieldName.'Transform'] ?? true; |
|
| 150 | 150 | $seoField = $fields['seoField']; |
| 151 | 151 | $tranformModeField = $fields['transformModeField']; |
| 152 | 152 | $transformMode = $bundleSettings[$tranformModeField] ?? 'crop'; |
| 153 | 153 | if (empty($transformMode)) { |
| 154 | 154 | $transformMode = 'crop'; |
| 155 | 155 | } |
| 156 | - $seoFieldWidth = $fields['seoField'] . 'Width'; |
|
| 157 | - $seoFieldHeight = $fields['seoField'] . 'Height'; |
|
| 156 | + $seoFieldWidth = $fields['seoField'].'Width'; |
|
| 157 | + $seoFieldHeight = $fields['seoField'].'Height'; |
|
| 158 | 158 | $transformName = $fields['transformName'] ?? 'base'; |
| 159 | 159 | // Quote all the things here for clarity |
| 160 | - $transformName = '"' . $transformName . '"'; |
|
| 161 | - $transformMode = '"' . $transformMode . '"'; |
|
| 160 | + $transformName = '"'.$transformName.'"'; |
|
| 161 | + $transformMode = '"'.$transformMode.'"'; |
|
| 162 | 162 | // Special-case Twitter transforms |
| 163 | 163 | if ($fieldName === 'twitterImage') { |
| 164 | 164 | $transformName = 'seomatic.helper.twitterTransform()'; |
@@ -173,30 +173,30 @@ discard block |
||
| 173 | 173 | if ($transformImage) { |
| 174 | 174 | switch ($source) { |
| 175 | 175 | case 'sameAsSeo': |
| 176 | - $seoSource = $bundleSettings[$seoField . 'Source'] ?? ''; |
|
| 177 | - $seoIds = $bundleSettings[$seoField . 'Ids'] ?? []; |
|
| 178 | - $seoSourceField = $bundleSettings[$seoField . 'Field'] ?? ''; |
|
| 176 | + $seoSource = $bundleSettings[$seoField.'Source'] ?? ''; |
|
| 177 | + $seoIds = $bundleSettings[$seoField.'Ids'] ?? []; |
|
| 178 | + $seoSourceField = $bundleSettings[$seoField.'Field'] ?? ''; |
|
| 179 | 179 | if (!empty($seoSource)) { |
| 180 | 180 | switch ($seoSource) { |
| 181 | 181 | case 'fromField': |
| 182 | 182 | if (!empty($seoSourceField)) { |
| 183 | 183 | $globalsSettings[$fieldName] = '{{ seomatic.helper.socialTransform(' |
| 184 | - . $objectPrefix . $elementName . $seoSourceField |
|
| 185 | - . ', ' . $transformName |
|
| 186 | - . ', ' . $siteId |
|
| 187 | - . ', ' . $transformMode |
|
| 184 | + . $objectPrefix.$elementName.$seoSourceField |
|
| 185 | + . ', '.$transformName |
|
| 186 | + . ', '.$siteId |
|
| 187 | + . ', '.$transformMode |
|
| 188 | 188 | . ') }}'; |
| 189 | 189 | $globalsSettings[$fieldNameWidth] = '{{ seomatic.helper.socialTransformWidth(' |
| 190 | - . $objectPrefix . $elementName . $seoSourceField |
|
| 191 | - . ', ' . $transformName |
|
| 192 | - . ', ' . $siteId |
|
| 193 | - . ', ' . $transformMode |
|
| 190 | + . $objectPrefix.$elementName.$seoSourceField |
|
| 191 | + . ', '.$transformName |
|
| 192 | + . ', '.$siteId |
|
| 193 | + . ', '.$transformMode |
|
| 194 | 194 | . ') }}'; |
| 195 | 195 | $globalsSettings[$fieldNameHeight] = '{{ seomatic.helper.socialTransformHeight(' |
| 196 | - . $objectPrefix . $elementName . $seoSourceField |
|
| 197 | - . ', ' . $transformName |
|
| 198 | - . ', ' . $siteId |
|
| 199 | - . ', ' . $transformMode |
|
| 196 | + . $objectPrefix.$elementName.$seoSourceField |
|
| 197 | + . ', '.$transformName |
|
| 198 | + . ', '.$siteId |
|
| 199 | + . ', '.$transformMode |
|
| 200 | 200 | . ') }}'; |
| 201 | 201 | } |
| 202 | 202 | break; |
@@ -204,28 +204,28 @@ discard block |
||
| 204 | 204 | if (!empty($seoIds)) { |
| 205 | 205 | $globalsSettings[$fieldName] = '{{ seomatic.helper.socialTransform(' |
| 206 | 206 | . $seoIds[0] |
| 207 | - . ', ' . $transformName |
|
| 208 | - . ', ' . $siteId |
|
| 209 | - . ', ' . $transformMode |
|
| 207 | + . ', '.$transformName |
|
| 208 | + . ', '.$siteId |
|
| 209 | + . ', '.$transformMode |
|
| 210 | 210 | . ') }}'; |
| 211 | 211 | $globalsSettings[$fieldNameWidth] = '{{ seomatic.helper.socialTransformWidth(' |
| 212 | 212 | . $seoIds[0] |
| 213 | - . ', ' . $transformName |
|
| 214 | - . ', ' . $siteId |
|
| 215 | - . ', ' . $transformMode |
|
| 213 | + . ', '.$transformName |
|
| 214 | + . ', '.$siteId |
|
| 215 | + . ', '.$transformMode |
|
| 216 | 216 | . ') }}'; |
| 217 | 217 | $globalsSettings[$fieldNameHeight] = '{{ seomatic.helper.socialTransformHeight(' |
| 218 | 218 | . $seoIds[0] |
| 219 | - . ', ' . $transformName |
|
| 220 | - . ', ' . $siteId |
|
| 221 | - . ', ' . $transformMode |
|
| 219 | + . ', '.$transformName |
|
| 220 | + . ', '.$siteId |
|
| 221 | + . ', '.$transformMode |
|
| 222 | 222 | . ') }}'; |
| 223 | 223 | } |
| 224 | 224 | break; |
| 225 | 225 | default: |
| 226 | - $globalsSettings[$fieldName] = '{{ seomatic.meta.' . $seoField . ' }}'; |
|
| 227 | - $globalsSettings[$fieldNameWidth] = '{{ seomatic.meta.' . $seoFieldWidth . ' }}'; |
|
| 228 | - $globalsSettings[$fieldNameHeight] = '{{ seomatic.meta.' . $seoFieldHeight . ' }}'; |
|
| 226 | + $globalsSettings[$fieldName] = '{{ seomatic.meta.'.$seoField.' }}'; |
|
| 227 | + $globalsSettings[$fieldNameWidth] = '{{ seomatic.meta.'.$seoFieldWidth.' }}'; |
|
| 228 | + $globalsSettings[$fieldNameHeight] = '{{ seomatic.meta.'.$seoFieldHeight.' }}'; |
|
| 229 | 229 | break; |
| 230 | 230 | } |
| 231 | 231 | } |
@@ -233,22 +233,22 @@ discard block |
||
| 233 | 233 | case 'fromField': |
| 234 | 234 | if (!empty($sourceField)) { |
| 235 | 235 | $globalsSettings[$fieldName] = '{{ seomatic.helper.socialTransform(' |
| 236 | - . $objectPrefix . $elementName . $sourceField |
|
| 237 | - . ', ' . $transformName |
|
| 238 | - . ', ' . $siteId |
|
| 239 | - . ', ' . $transformMode |
|
| 236 | + . $objectPrefix.$elementName.$sourceField |
|
| 237 | + . ', '.$transformName |
|
| 238 | + . ', '.$siteId |
|
| 239 | + . ', '.$transformMode |
|
| 240 | 240 | . ') }}'; |
| 241 | 241 | $globalsSettings[$fieldNameWidth] = '{{ seomatic.helper.socialTransformWidth(' |
| 242 | - . $objectPrefix . $elementName . $sourceField |
|
| 243 | - . ', ' . $transformName |
|
| 244 | - . ', ' . $siteId |
|
| 245 | - . ', ' . $transformMode |
|
| 242 | + . $objectPrefix.$elementName.$sourceField |
|
| 243 | + . ', '.$transformName |
|
| 244 | + . ', '.$siteId |
|
| 245 | + . ', '.$transformMode |
|
| 246 | 246 | . ') }}'; |
| 247 | 247 | $globalsSettings[$fieldNameHeight] = '{{ seomatic.helper.socialTransformHeight(' |
| 248 | - . $objectPrefix . $elementName . $sourceField |
|
| 249 | - . ', ' . $transformName |
|
| 250 | - . ', ' . $siteId |
|
| 251 | - . ', ' . $transformMode |
|
| 248 | + . $objectPrefix.$elementName.$sourceField |
|
| 249 | + . ', '.$transformName |
|
| 250 | + . ', '.$siteId |
|
| 251 | + . ', '.$transformMode |
|
| 252 | 252 | . ') }}'; |
| 253 | 253 | } |
| 254 | 254 | break; |
@@ -256,21 +256,21 @@ discard block |
||
| 256 | 256 | if (!empty($ids)) { |
| 257 | 257 | $globalsSettings[$fieldName] = '{{ seomatic.helper.socialTransform(' |
| 258 | 258 | . $ids[0] |
| 259 | - . ', ' . $transformName |
|
| 260 | - . ', ' . $siteId |
|
| 261 | - . ', ' . $transformMode |
|
| 259 | + . ', '.$transformName |
|
| 260 | + . ', '.$siteId |
|
| 261 | + . ', '.$transformMode |
|
| 262 | 262 | . ') }}'; |
| 263 | 263 | $globalsSettings[$fieldNameWidth] = '{{ seomatic.helper.socialTransformWidth(' |
| 264 | 264 | . $ids[0] |
| 265 | - . ', ' . $transformName |
|
| 266 | - . ', ' . $siteId |
|
| 267 | - . ', ' . $transformMode |
|
| 265 | + . ', '.$transformName |
|
| 266 | + . ', '.$siteId |
|
| 267 | + . ', '.$transformMode |
|
| 268 | 268 | . ') }}'; |
| 269 | 269 | $globalsSettings[$fieldNameHeight] = '{{ seomatic.helper.socialTransformHeight(' |
| 270 | 270 | . $ids[0] |
| 271 | - . ', ' . $transformName |
|
| 272 | - . ', ' . $siteId |
|
| 273 | - . ', ' . $transformMode |
|
| 271 | + . ', '.$transformName |
|
| 272 | + . ', '.$siteId |
|
| 273 | + . ', '.$transformMode |
|
| 274 | 274 | . ') }}'; |
| 275 | 275 | } |
| 276 | 276 | break; |
@@ -278,20 +278,20 @@ discard block |
||
| 278 | 278 | } else { |
| 279 | 279 | switch ($source) { |
| 280 | 280 | case 'sameAsSeo': |
| 281 | - $globalsSettings[$fieldName] = '{{ seomatic.meta.' . $seoField . ' }}'; |
|
| 282 | - $globalsSettings[$fieldNameWidth] = '{{ seomatic.meta.' . $seoFieldWidth . ' }}'; |
|
| 283 | - $globalsSettings[$fieldNameHeight] = '{{ seomatic.meta.' . $seoFieldHeight . ' }}'; |
|
| 281 | + $globalsSettings[$fieldName] = '{{ seomatic.meta.'.$seoField.' }}'; |
|
| 282 | + $globalsSettings[$fieldNameWidth] = '{{ seomatic.meta.'.$seoFieldWidth.' }}'; |
|
| 283 | + $globalsSettings[$fieldNameHeight] = '{{ seomatic.meta.'.$seoFieldHeight.' }}'; |
|
| 284 | 284 | break; |
| 285 | 285 | case 'fromField': |
| 286 | 286 | if (!empty($sourceField)) { |
| 287 | 287 | $globalsSettings[$fieldName] = '{{ ' |
| 288 | - . $elementName . $sourceField . '[0].url' |
|
| 288 | + . $elementName.$sourceField.'[0].url' |
|
| 289 | 289 | . ' }}'; |
| 290 | 290 | $globalsSettings[$fieldNameWidth] = '{{ ' |
| 291 | - . $elementName . $sourceField . '[0].width' |
|
| 291 | + . $elementName.$sourceField.'[0].width' |
|
| 292 | 292 | . ' }}'; |
| 293 | 293 | $globalsSettings[$fieldNameHeight] = '{{ ' |
| 294 | - . $elementName . $sourceField . '[0].height' |
|
| 294 | + . $elementName.$sourceField.'[0].height' |
|
| 295 | 295 | . ' }}'; |
| 296 | 296 | } |
| 297 | 297 | break; |
@@ -299,13 +299,13 @@ discard block |
||
| 299 | 299 | if (!empty($ids)) { |
| 300 | 300 | $globalsSettings[$fieldName] = '{{ craft.app.assets.assetById(' |
| 301 | 301 | . $ids[0] |
| 302 | - . ', ' . $siteId . ').url }}'; |
|
| 302 | + . ', '.$siteId.').url }}'; |
|
| 303 | 303 | $globalsSettings[$fieldNameWidth] = '{{ craft.app.assets.assetById(' |
| 304 | 304 | . $ids[0] |
| 305 | - . ', ' . $siteId . ').width }}'; |
|
| 305 | + . ', '.$siteId.').width }}'; |
|
| 306 | 306 | $globalsSettings[$fieldNameHeight] = '{{ craft.app.assets.assetById(' |
| 307 | 307 | . $ids[0] |
| 308 | - . ', ' . $siteId . ').height }}'; |
|
| 308 | + . ', '.$siteId.').height }}'; |
|
| 309 | 309 | } |
| 310 | 310 | break; |
| 311 | 311 | } |