@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @inheritdoc |
54 | 54 | */ |
55 | - public function create($config = [], $add = true): MetaLink |
|
55 | + public function create($config = [ ], $add = true): MetaLink |
|
56 | 56 | { |
57 | 57 | $metaItem = MetaLink::create($config); |
58 | 58 | if ($add && !empty($metaItem)) { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function add($metaItem, string $handle = self::GENERAL_HANDLE) |
69 | 69 | { |
70 | - $key = MetaLinkContainer::CONTAINER_TYPE.$handle; |
|
70 | + $key = MetaLinkContainer::CONTAINER_TYPE . $handle; |
|
71 | 71 | Seomatic::$plugin->metaContainers->addToMetaContainer($metaItem, $key); |
72 | 72 | |
73 | 73 | /** @var MetaLink $metaItem */ |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function container(string $handle = self::GENERAL_HANDLE) |
93 | 93 | { |
94 | - $key = MetaLinkContainer::CONTAINER_TYPE.$handle; |
|
94 | + $key = MetaLinkContainer::CONTAINER_TYPE . $handle; |
|
95 | 95 | |
96 | 96 | return Seomatic::$plugin->metaContainers->getMetaContainer($key); |
97 | 97 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * @inheritdoc |
51 | 51 | */ |
52 | - public function create($config = [], $add = true): MetaTitle |
|
52 | + public function create($config = [ ], $add = true): MetaTitle |
|
53 | 53 | { |
54 | 54 | $metaItem = MetaTitle::create($config); |
55 | 55 | if ($add && !empty($metaItem)) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function add($metaItem, string $handle = self::GENERAL_HANDLE) |
66 | 66 | { |
67 | - $key = MetaTitleContainer::CONTAINER_TYPE.$handle; |
|
67 | + $key = MetaTitleContainer::CONTAINER_TYPE . $handle; |
|
68 | 68 | Seomatic::$plugin->metaContainers->addToMetaContainer($metaItem, $key); |
69 | 69 | |
70 | 70 | /** @var MetaTitle $metaItem */ |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function container(string $handle = self::GENERAL_HANDLE) |
90 | 90 | { |
91 | - $key = MetaTitleContainer::CONTAINER_TYPE.$handle; |
|
91 | + $key = MetaTitleContainer::CONTAINER_TYPE . $handle; |
|
92 | 92 | |
93 | 93 | return Seomatic::$plugin->metaContainers->getMetaContainer($key); |
94 | 94 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * @inheritdoc |
51 | 51 | */ |
52 | - public function create($config = [], $add = true): MetaScript |
|
52 | + public function create($config = [ ], $add = true): MetaScript |
|
53 | 53 | { |
54 | 54 | $metaItem = MetaScript::create($config); |
55 | 55 | if ($add && !empty($metaItem)) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function add($metaItem, string $handle = self::GENERAL_HANDLE) |
66 | 66 | { |
67 | - $key = MetaScriptContainer::CONTAINER_TYPE.$handle; |
|
67 | + $key = MetaScriptContainer::CONTAINER_TYPE . $handle; |
|
68 | 68 | Seomatic::$plugin->metaContainers->addToMetaContainer($metaItem, $key); |
69 | 69 | |
70 | 70 | /** @var MetaScript $metaItem */ |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function container(string $handle = self::GENERAL_HANDLE) |
90 | 90 | { |
91 | - $key = MetaScriptContainer::CONTAINER_TYPE.$handle; |
|
91 | + $key = MetaScriptContainer::CONTAINER_TYPE . $handle; |
|
92 | 92 | |
93 | 93 | return Seomatic::$plugin->metaContainers->getMetaContainer($key); |
94 | 94 | } |
@@ -59,22 +59,22 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * @var MetaBundle[] indexed by [id] |
61 | 61 | */ |
62 | - protected $metaBundles = []; |
|
62 | + protected $metaBundles = [ ]; |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @var array indexed by [sourceId][sourceSiteId] = id |
66 | 66 | */ |
67 | - protected $metaBundlesBySourceId = []; |
|
67 | + protected $metaBundlesBySourceId = [ ]; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @var array indexed by [sourceHandle][sourceSiteId] = id |
71 | 71 | */ |
72 | - protected $metaBundlesBySourceHandle = []; |
|
72 | + protected $metaBundlesBySourceHandle = [ ]; |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @var array indexed by [sourceSiteId] = id |
76 | 76 | */ |
77 | - protected $globalMetaBundles = []; |
|
77 | + protected $globalMetaBundles = [ ]; |
|
78 | 78 | |
79 | 79 | // Public Methods |
80 | 80 | // ========================================================================= |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | { |
91 | 91 | $metaBundle = null; |
92 | 92 | // See if we have the meta bundle cached |
93 | - if (!empty($this->globalMetaBundles[$sourceSiteId])) { |
|
94 | - return $this->globalMetaBundles[$sourceSiteId]; |
|
93 | + if (!empty($this->globalMetaBundles[ $sourceSiteId ])) { |
|
94 | + return $this->globalMetaBundles[ $sourceSiteId ]; |
|
95 | 95 | } |
96 | 96 | $metaBundleArray = (new Query()) |
97 | - ->from(['{{%seomatic_metabundles}}']) |
|
97 | + ->from([ '{{%seomatic_metabundles}}' ]) |
|
98 | 98 | ->where([ |
99 | 99 | 'sourceBundleType' => self::GLOBAL_META_BUNDLE, |
100 | 100 | 'sourceSiteId' => $sourceSiteId, |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $metaBundle = $this->createGlobalMetaBundleForSite($sourceSiteId); |
111 | 111 | } |
112 | 112 | // Cache it for future accesses |
113 | - $this->globalMetaBundles[$sourceSiteId] = $metaBundle; |
|
113 | + $this->globalMetaBundles[ $sourceSiteId ] = $metaBundle; |
|
114 | 114 | |
115 | 115 | return $metaBundle; |
116 | 116 | } |
@@ -170,15 +170,15 @@ discard block |
||
170 | 170 | { |
171 | 171 | $metaBundle = null; |
172 | 172 | // See if we have the meta bundle cached |
173 | - if (!empty($this->metaBundlesBySourceId[$sourceBundleType][$sourceId][$sourceSiteId])) { |
|
174 | - $id = $this->metaBundlesBySourceId[$sourceBundleType][$sourceId][$sourceSiteId]; |
|
175 | - if (!empty($this->metaBundles[$id])) { |
|
176 | - return $this->metaBundles[$id]; |
|
173 | + if (!empty($this->metaBundlesBySourceId[ $sourceBundleType ][ $sourceId ][ $sourceSiteId ])) { |
|
174 | + $id = $this->metaBundlesBySourceId[ $sourceBundleType ][ $sourceId ][ $sourceSiteId ]; |
|
175 | + if (!empty($this->metaBundles[ $id ])) { |
|
176 | + return $this->metaBundles[ $id ]; |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | // Look for a matching meta bundle in the db |
180 | 180 | $metaBundleArray = (new Query()) |
181 | - ->from(['{{%seomatic_metabundles}}']) |
|
181 | + ->from([ '{{%seomatic_metabundles}}' ]) |
|
182 | 182 | ->where([ |
183 | 183 | 'sourceBundleType' => $sourceBundleType, |
184 | 184 | 'sourceId' => $sourceId, |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | $metaBundle = MetaBundle::create($metaBundleArray); |
192 | 192 | $this->syncBundleWithConfig($sourceBundleType, $metaBundle); |
193 | 193 | $id = count($this->metaBundles); |
194 | - $this->metaBundles[$id] = $metaBundle; |
|
195 | - $this->metaBundlesBySourceId[$sourceBundleType][$sourceId][$sourceSiteId] = $id; |
|
194 | + $this->metaBundles[ $id ] = $metaBundle; |
|
195 | + $this->metaBundlesBySourceId[ $sourceBundleType ][ $sourceId ][ $sourceSiteId ] = $id; |
|
196 | 196 | } else { |
197 | 197 | // If it doesn't exist, create it |
198 | 198 | switch ($sourceBundleType) { |
@@ -224,15 +224,15 @@ discard block |
||
224 | 224 | { |
225 | 225 | $metaBundle = null; |
226 | 226 | // See if we have the meta bundle cached |
227 | - if (!empty($this->metaBundlesBySourceHandle[$sourceType][$sourceHandle][$sourceSiteId])) { |
|
228 | - $id = $this->metaBundlesBySourceHandle[$sourceType][$sourceHandle][$sourceSiteId]; |
|
229 | - if (!empty($this->metaBundles[$id])) { |
|
230 | - return $this->metaBundles[$id]; |
|
227 | + if (!empty($this->metaBundlesBySourceHandle[ $sourceType ][ $sourceHandle ][ $sourceSiteId ])) { |
|
228 | + $id = $this->metaBundlesBySourceHandle[ $sourceType ][ $sourceHandle ][ $sourceSiteId ]; |
|
229 | + if (!empty($this->metaBundles[ $id ])) { |
|
230 | + return $this->metaBundles[ $id ]; |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | // Look for a matching meta bundle in the db |
234 | 234 | $metaBundleArray = (new Query()) |
235 | - ->from(['{{%seomatic_metabundles}}']) |
|
235 | + ->from([ '{{%seomatic_metabundles}}' ]) |
|
236 | 236 | ->where([ |
237 | 237 | 'sourceHandle' => $sourceHandle, |
238 | 238 | 'sourceSiteId' => $sourceSiteId, |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | $metaBundleArray = array_diff_key($metaBundleArray, array_flip(self::IGNORE_DB_ATTRIBUTES)); |
243 | 243 | $metaBundle = MetaBundle::create($metaBundleArray); |
244 | 244 | $id = count($this->metaBundles); |
245 | - $this->metaBundles[$id] = $metaBundle; |
|
246 | - $this->metaBundlesBySourceHandle[$sourceType][$sourceHandle][$sourceSiteId] = $id; |
|
245 | + $this->metaBundles[ $id ] = $metaBundle; |
|
246 | + $this->metaBundlesBySourceHandle[ $sourceType ][ $sourceHandle ][ $sourceSiteId ] = $id; |
|
247 | 247 | } else { |
248 | 248 | // If it doesn't exist, create it |
249 | 249 | switch ($sourceType) { |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | // @TODO: handle commerce products |
464 | 464 | } |
465 | 465 | |
466 | - return [$sourceId, $sourceBundleType, $sourceHandle, $sourceSiteId]; |
|
466 | + return [ $sourceId, $sourceBundleType, $sourceHandle, $sourceSiteId ]; |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -475,26 +475,26 @@ discard block |
||
475 | 475 | */ |
476 | 476 | public function getContentMetaBundles(bool $allSites = true): array |
477 | 477 | { |
478 | - $metaBundles = []; |
|
479 | - $metaBundleSourceHandles = []; |
|
478 | + $metaBundles = [ ]; |
|
479 | + $metaBundleSourceHandles = [ ]; |
|
480 | 480 | $metaBundleArrays = (new Query()) |
481 | - ->from(['{{%seomatic_metabundles}}']) |
|
482 | - ->where(['!=', 'sourceBundleType', self::GLOBAL_META_BUNDLE]) |
|
481 | + ->from([ '{{%seomatic_metabundles}}' ]) |
|
482 | + ->where([ '!=', 'sourceBundleType', self::GLOBAL_META_BUNDLE ]) |
|
483 | 483 | ->all(); |
484 | 484 | /** @var $metaBundleArray array */ |
485 | 485 | foreach ($metaBundleArrays as $metaBundleArray) { |
486 | 486 | $addToMetaBundles = true; |
487 | 487 | if (!$allSites) { |
488 | - if (in_array($metaBundleArray['sourceHandle'], $metaBundleSourceHandles)) { |
|
488 | + if (in_array($metaBundleArray[ 'sourceHandle' ], $metaBundleSourceHandles)) { |
|
489 | 489 | $addToMetaBundles = false; |
490 | 490 | } |
491 | - $metaBundleSourceHandles[] = $metaBundleArray['sourceHandle']; |
|
491 | + $metaBundleSourceHandles[ ] = $metaBundleArray[ 'sourceHandle' ]; |
|
492 | 492 | } |
493 | 493 | if ($addToMetaBundles) { |
494 | 494 | $metaBundleArray = array_diff_key($metaBundleArray, array_flip(self::IGNORE_DB_ATTRIBUTES)); |
495 | 495 | $metaBundle = MetaBundle::create($metaBundleArray); |
496 | 496 | if ($metaBundle) { |
497 | - $metaBundles[] = $metaBundle; |
|
497 | + $metaBundles[ ] = $metaBundle; |
|
498 | 498 | } |
499 | 499 | } |
500 | 500 | } |
@@ -504,20 +504,20 @@ discard block |
||
504 | 504 | |
505 | 505 | public function getContentMetaBundlesForSiteId(int $sourceSiteId): array |
506 | 506 | { |
507 | - $metaBundles = []; |
|
507 | + $metaBundles = [ ]; |
|
508 | 508 | $metaBundleArrays = (new Query()) |
509 | - ->from(['{{%seomatic_metabundles}}']) |
|
509 | + ->from([ '{{%seomatic_metabundles}}' ]) |
|
510 | 510 | ->where([ |
511 | 511 | 'sourceSiteId' => $sourceSiteId, |
512 | 512 | ]) |
513 | - ->andWhere(['!=', 'sourceBundleType', self::GLOBAL_META_BUNDLE]) |
|
513 | + ->andWhere([ '!=', 'sourceBundleType', self::GLOBAL_META_BUNDLE ]) |
|
514 | 514 | ->all(); |
515 | 515 | /** @var $metaBundleArray array */ |
516 | 516 | foreach ($metaBundleArrays as $metaBundleArray) { |
517 | 517 | $metaBundleArray = array_diff_key($metaBundleArray, array_flip(self::IGNORE_DB_ATTRIBUTES)); |
518 | 518 | $metaBundle = MetaBundle::create($metaBundleArray); |
519 | 519 | if ($metaBundle) { |
520 | - $metaBundles[] = $metaBundle; |
|
520 | + $metaBundles[ ] = $metaBundle; |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
@@ -534,11 +534,11 @@ discard block |
||
534 | 534 | */ |
535 | 535 | public function getContainerDataFromBundle(MetaBundle $bundle, string $type) |
536 | 536 | { |
537 | - $containerData = []; |
|
537 | + $containerData = [ ]; |
|
538 | 538 | foreach ($bundle->metaContainers as $metaContainer) { |
539 | 539 | if ($metaContainer::CONTAINER_TYPE == $type) { |
540 | 540 | foreach ($metaContainer->data as $dataHandle => $data) { |
541 | - $containerData[$dataHandle] = $data; |
|
541 | + $containerData[ $dataHandle ] = $data; |
|
542 | 542 | } |
543 | 543 | } |
544 | 544 | } |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | */ |
590 | 590 | protected function syncBundleWithConfig(string $sourceType, MetaBundle &$metaBundle) |
591 | 591 | { |
592 | - $config = []; |
|
592 | + $config = [ ]; |
|
593 | 593 | switch ($sourceType) { |
594 | 594 | case self::GLOBAL_META_BUNDLE: |
595 | 595 | $config = ConfigHelper::getConfigFromFile('globalmeta/Bundle'); |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | } |
605 | 605 | // If the config file has a newer version than the $metaBundleArray, merge them |
606 | 606 | if (!empty($config)) { |
607 | - if (version_compare($config['bundleVersion'], $metaBundle->bundleVersion, '>')) { |
|
607 | + if (version_compare($config[ 'bundleVersion' ], $metaBundle->bundleVersion, '>')) { |
|
608 | 608 | $metaBundleArray = $metaBundle->toArray(); |
609 | 609 | // Create a new meta bundle |
610 | 610 | switch ($sourceType) { |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * |
643 | 643 | * @return MetaBundle |
644 | 644 | */ |
645 | - protected function createGlobalMetaBundleForSite(int $siteId, $baseConfig = []): MetaBundle |
|
645 | + protected function createGlobalMetaBundleForSite(int $siteId, $baseConfig = [ ]): MetaBundle |
|
646 | 646 | { |
647 | 647 | // Create a new meta bundle with propagated defaults |
648 | 648 | $metaBundleDefaults = ArrayHelper::merge( |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | // Remove any empty keys from our file-based config |
655 | 655 | $metaBundleDefaults = ArrayHelper::arrayFilterRecursive( |
656 | 656 | $metaBundleDefaults, |
657 | - [ArrayHelper::class, 'unsetEmptyChildren'] |
|
657 | + [ ArrayHelper::class, 'unsetEmptyChildren' ] |
|
658 | 658 | ); |
659 | 659 | // Merge them together |
660 | 660 | $metaBundle = MetaBundle::create(ArrayHelper::merge( |
@@ -675,32 +675,32 @@ discard block |
||
675 | 675 | * |
676 | 676 | * @return null|MetaBundle |
677 | 677 | */ |
678 | - protected function createMetaBundleFromSection(Section $section, int $siteId, $baseConfig = []) |
|
678 | + protected function createMetaBundleFromSection(Section $section, int $siteId, $baseConfig = [ ]) |
|
679 | 679 | { |
680 | 680 | $metaBundle = null; |
681 | 681 | // Get the site settings and turn them into arrays |
682 | 682 | $siteSettings = $section->getSiteSettings(); |
683 | - if (!empty($siteSettings[$siteId])) { |
|
684 | - $siteSettingsArray = []; |
|
683 | + if (!empty($siteSettings[ $siteId ])) { |
|
684 | + $siteSettingsArray = [ ]; |
|
685 | 685 | /** @var $siteSetting Section_SiteSettings */ |
686 | 686 | foreach ($siteSettings as $siteSetting) { |
687 | 687 | if ($siteSetting->hasUrls) { |
688 | 688 | $siteSettingArray = $siteSetting->toArray(); |
689 | 689 | // Get the site language |
690 | - $siteSettingArray['language'] = MetaValue::getSiteLanguage($siteSetting->siteId); |
|
691 | - $siteSettingsArray[] = $siteSettingArray; |
|
690 | + $siteSettingArray[ 'language' ] = MetaValue::getSiteLanguage($siteSetting->siteId); |
|
691 | + $siteSettingsArray[ ] = $siteSettingArray; |
|
692 | 692 | } |
693 | 693 | } |
694 | 694 | $siteSettingsArray = ArrayHelper::index($siteSettingsArray, 'siteId'); |
695 | 695 | // Create a MetaBundle for this site |
696 | - $siteSetting = $siteSettings[$siteId]; |
|
696 | + $siteSetting = $siteSettings[ $siteId ]; |
|
697 | 697 | if ($siteSetting->hasUrls) { |
698 | 698 | // Get the most recent dateUpdated |
699 | 699 | $element = Entry::find() |
700 | 700 | ->section($section->handle) |
701 | 701 | ->siteId($siteSetting->siteId) |
702 | 702 | ->limit(1) |
703 | - ->orderBy(['elements.dateUpdated' => SORT_DESC]) |
|
703 | + ->orderBy([ 'elements.dateUpdated' => SORT_DESC ]) |
|
704 | 704 | ->one(); |
705 | 705 | if ($element) { |
706 | 706 | $dateUpdated = $element->dateUpdated ?? $element->dateCreated; |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | // Remove any empty keys from our file-based config |
725 | 725 | $metaBundleDefaults = ArrayHelper::arrayFilterRecursive( |
726 | 726 | $metaBundleDefaults, |
727 | - [ArrayHelper::class, 'unsetEmptyChildren'] |
|
727 | + [ ArrayHelper::class, 'unsetEmptyChildren' ] |
|
728 | 728 | ); |
729 | 729 | // Merge them together |
730 | 730 | $metaBundle = MetaBundle::create(ArrayHelper::merge( |
@@ -747,32 +747,32 @@ discard block |
||
747 | 747 | * |
748 | 748 | * @return null|MetaBundle |
749 | 749 | */ |
750 | - protected function createMetaBundleFromCategory(CategoryGroup $category, int $siteId, $baseConfig = []) |
|
750 | + protected function createMetaBundleFromCategory(CategoryGroup $category, int $siteId, $baseConfig = [ ]) |
|
751 | 751 | { |
752 | 752 | $metaBundle = null; |
753 | 753 | // Get the site settings and turn them into arrays |
754 | 754 | $siteSettings = $category->getSiteSettings(); |
755 | - if (!empty($siteSettings[$siteId])) { |
|
756 | - $siteSettingsArray = []; |
|
755 | + if (!empty($siteSettings[ $siteId ])) { |
|
756 | + $siteSettingsArray = [ ]; |
|
757 | 757 | /** @var $siteSetting CategoryGroup_SiteSettings */ |
758 | 758 | foreach ($siteSettings as $siteSetting) { |
759 | 759 | if ($siteSetting->hasUrls) { |
760 | 760 | $siteSettingArray = $siteSetting->toArray(); |
761 | 761 | // Get the site language |
762 | - $siteSettingArray['language'] = MetaValue::getSiteLanguage($siteSetting->siteId); |
|
763 | - $siteSettingsArray[] = $siteSettingArray; |
|
762 | + $siteSettingArray[ 'language' ] = MetaValue::getSiteLanguage($siteSetting->siteId); |
|
763 | + $siteSettingsArray[ ] = $siteSettingArray; |
|
764 | 764 | } |
765 | 765 | } |
766 | 766 | $siteSettingsArray = ArrayHelper::index($siteSettingsArray, 'siteId'); |
767 | 767 | // Create a MetaBundle for this site |
768 | - $siteSetting = $siteSettings[$siteId]; |
|
768 | + $siteSetting = $siteSettings[ $siteId ]; |
|
769 | 769 | if ($siteSetting->hasUrls) { |
770 | 770 | // Get the most recent dateUpdated |
771 | 771 | $element = Category::find() |
772 | 772 | ->group($category->handle) |
773 | 773 | ->siteId($siteSetting->siteId) |
774 | 774 | ->limit(1) |
775 | - ->orderBy(['elements.dateUpdated' => SORT_DESC]) |
|
775 | + ->orderBy([ 'elements.dateUpdated' => SORT_DESC ]) |
|
776 | 776 | ->one(); |
777 | 777 | if ($element) { |
778 | 778 | $dateUpdated = $element->dateUpdated ?? $element->dateCreated; |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * @inheritdoc |
58 | 58 | */ |
59 | - public function create($config = [], $add = true): MetaTag |
|
59 | + public function create($config = [ ], $add = true): MetaTag |
|
60 | 60 | { |
61 | 61 | $type = self::DEFAULT_TYPE; |
62 | - if (!empty($config['type'])) { |
|
62 | + if (!empty($config[ 'type' ])) { |
|
63 | 63 | $type = ArrayHelper::remove($config, 'type'); |
64 | 64 | } |
65 | 65 | $metaItem = MetaTag::create($type, $config); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function add($metaItem, string $handle = self::GENERAL_HANDLE) |
77 | 77 | { |
78 | - $key = MetaTagContainer::CONTAINER_TYPE.$handle; |
|
78 | + $key = MetaTagContainer::CONTAINER_TYPE . $handle; |
|
79 | 79 | Seomatic::$plugin->metaContainers->addToMetaContainer($metaItem, $key); |
80 | 80 | |
81 | 81 | /** @var MetaTag $metaItem */ |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function container(string $handle = self::GENERAL_HANDLE) |
101 | 101 | { |
102 | - $key = MetaTagContainer::CONTAINER_TYPE.$handle; |
|
102 | + $key = MetaTagContainer::CONTAINER_TYPE . $handle; |
|
103 | 103 | |
104 | 104 | return Seomatic::$plugin->metaContainers->getMetaContainer($key); |
105 | 105 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | Event::on( |
94 | 94 | UrlManager::class, |
95 | 95 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
96 | - function (RegisterUrlRulesEvent $event) { |
|
96 | + function(RegisterUrlRulesEvent $event) { |
|
97 | 97 | Craft::debug( |
98 | 98 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
99 | 99 | __METHOD__ |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function frontendTemplateRouteRules(): array |
114 | 114 | { |
115 | - $rules = []; |
|
115 | + $rules = [ ]; |
|
116 | 116 | foreach ($this->frontendTemplateContainer->data as $frontendTemplate) { |
117 | 117 | if ($frontendTemplate->include) { |
118 | 118 | /** @var $frontendTemplate FrontendTemplate */ |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return string |
134 | 134 | */ |
135 | - public function renderTemplate(string $template, $params = []): string |
|
135 | + public function renderTemplate(string $template, $params = [ ]): string |
|
136 | 136 | { |
137 | 137 | $duration = Seomatic::$devMode |
138 | 138 | ? $this::DEVMODE_FRONTENDTEMPLATE_CACHE_DURATION |
@@ -146,15 +146,15 @@ discard block |
||
146 | 146 | $cache = Craft::$app->getCache(); |
147 | 147 | $html = $cache->getOrSet( |
148 | 148 | $this::CACHE_KEY . $template, |
149 | - function () use ($template, $params) { |
|
149 | + function() use ($template, $params) { |
|
150 | 150 | Craft::info( |
151 | 151 | 'Frontend template cache miss: ' . $template, |
152 | 152 | __METHOD__ |
153 | 153 | ); |
154 | 154 | $html = ''; |
155 | - if (!empty($this->frontendTemplateContainer->data[$template])) { |
|
155 | + if (!empty($this->frontendTemplateContainer->data[ $template ])) { |
|
156 | 156 | /** @var $frontendTemplate FrontendTemplate */ |
157 | - $frontendTemplate = $this->frontendTemplateContainer->data[$template]; |
|
157 | + $frontendTemplate = $this->frontendTemplateContainer->data[ $template ]; |
|
158 | 158 | $html = $frontendTemplate->render($params); |
159 | 159 | } |
160 | 160 |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * @var MetaContainer |
81 | 81 | */ |
82 | - protected $metaContainers = []; |
|
82 | + protected $metaContainers = [ ]; |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @var bool |
@@ -127,23 +127,23 @@ discard block |
||
127 | 127 | $dependency = new TagDependency([ |
128 | 128 | 'tags' => [ |
129 | 129 | $this::GLOBAL_METACONTAINER_CACHE_TAG, |
130 | - $this::METACONTAINER_CACHE_TAG.$metaBundleSourceId, |
|
131 | - $this::METACONTAINER_CACHE_TAG.$uri.$siteId, |
|
130 | + $this::METACONTAINER_CACHE_TAG . $metaBundleSourceId, |
|
131 | + $this::METACONTAINER_CACHE_TAG . $uri . $siteId, |
|
132 | 132 | ], |
133 | 133 | ]); |
134 | 134 | $cache = Craft::$app->getCache(); |
135 | 135 | list($this->metaGlobalVars, $this->metaSiteVars, $this->metaSitemapVars, $this->metaContainers) = $cache->getOrSet( |
136 | - $this::CACHE_KEY.$uri.$siteId, |
|
137 | - function () use ($uri, $siteId) { |
|
136 | + $this::CACHE_KEY . $uri . $siteId, |
|
137 | + function() use ($uri, $siteId) { |
|
138 | 138 | Craft::info( |
139 | - 'Meta container cache miss: '.$uri.'/'.$siteId, |
|
139 | + 'Meta container cache miss: ' . $uri . '/' . $siteId, |
|
140 | 140 | __METHOD__ |
141 | 141 | ); |
142 | 142 | $this->loadGlobalMetaContainers($siteId); |
143 | 143 | $this->loadContentMetaContainers(); |
144 | 144 | DynamicMetaHelper::addDynamicMetaToContainers($uri, $siteId); |
145 | 145 | |
146 | - return [$this->metaGlobalVars, $this->metaSiteVars, $this->metaSitemapVars, $this->metaContainers]; |
|
146 | + return [ $this->metaGlobalVars, $this->metaSiteVars, $this->metaSitemapVars, $this->metaContainers ]; |
|
147 | 147 | }, |
148 | 148 | $duration, |
149 | 149 | $dependency |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | if (is_array($content)) { |
200 | 200 | $contentHeader = ''; |
201 | 201 | foreach ($content as $contentVal) { |
202 | - $contentHeader .= ($contentVal.','); |
|
202 | + $contentHeader .= ($contentVal . ','); |
|
203 | 203 | } |
204 | 204 | $contentHeader = rtrim($contentHeader, ','); |
205 | 205 | } else { |
@@ -273,18 +273,18 @@ discard block |
||
273 | 273 | */ |
274 | 274 | public function getMetaContainer(string $key) |
275 | 275 | { |
276 | - if (!$key || empty($this->metaContainers[$key])) { |
|
276 | + if (!$key || empty($this->metaContainers[ $key ])) { |
|
277 | 277 | $error = Craft::t( |
278 | 278 | 'seomatic', |
279 | 279 | 'Meta container with key `{key}` does not exist.', |
280 | - ['key' => $key] |
|
280 | + [ 'key' => $key ] |
|
281 | 281 | ); |
282 | 282 | Craft::error($error, __METHOD__); |
283 | 283 | |
284 | 284 | return null; |
285 | 285 | } |
286 | 286 | |
287 | - return $this->metaContainers[$key]; |
|
287 | + return $this->metaContainers[ $key ]; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | { |
300 | 300 | /** @var MetaContainer $container */ |
301 | 301 | $container = null; |
302 | - if (empty($this->metaContainers[$key])) { |
|
302 | + if (empty($this->metaContainers[ $key ])) { |
|
303 | 303 | /** @var MetaContainer $className */ |
304 | 304 | $className = null; |
305 | 305 | // Create a new container based on the type passed in |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | if ($className) { |
324 | 324 | $container = $className::create(); |
325 | 325 | if ($container) { |
326 | - $this->metaContainers[$key] = $container; |
|
326 | + $this->metaContainers[ $key ] = $container; |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | } |
@@ -341,11 +341,11 @@ discard block |
||
341 | 341 | */ |
342 | 342 | public function getContainersOfType(string $type): array |
343 | 343 | { |
344 | - $containers = []; |
|
344 | + $containers = [ ]; |
|
345 | 345 | /** @var $metaContainer MetaContainer */ |
346 | 346 | foreach ($this->metaContainers as $metaContainer) { |
347 | 347 | if ($metaContainer::CONTAINER_TYPE == $type) { |
348 | - $containers[] = $metaContainer; |
|
348 | + $containers[ ] = $metaContainer; |
|
349 | 349 | } |
350 | 350 | } |
351 | 351 | |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | */ |
386 | 386 | public function renderContainersArrayByType(string $type): array |
387 | 387 | { |
388 | - $htmlArray = []; |
|
388 | + $htmlArray = [ ]; |
|
389 | 389 | /** @var $metaContainer MetaContainer */ |
390 | 390 | foreach ($this->metaContainers as $metaContainer) { |
391 | 391 | if ($metaContainer::CONTAINER_TYPE == $type && $metaContainer->include) { |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | $this->metaGlobalVars->language = Seomatic::$language; |
448 | 448 | // Meta containers |
449 | 449 | foreach ($metaBundle->metaContainers as $key => $metaContainer) { |
450 | - $this->metaContainers[$key] = $metaContainer; |
|
450 | + $this->metaContainers[ $key ] = $metaContainer; |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | } |
@@ -578,9 +578,9 @@ discard block |
||
578 | 578 | $metaBundleSourceId = $sourceId; |
579 | 579 | } |
580 | 580 | $cache = Craft::$app->getCache(); |
581 | - TagDependency::invalidate($cache, $this::METACONTAINER_CACHE_TAG.$metaBundleSourceId); |
|
581 | + TagDependency::invalidate($cache, $this::METACONTAINER_CACHE_TAG . $metaBundleSourceId); |
|
582 | 582 | Craft::info( |
583 | - 'Meta bundle cache cleared: '.$metaBundleSourceId, |
|
583 | + 'Meta bundle cache cleared: ' . $metaBundleSourceId, |
|
584 | 584 | __METHOD__ |
585 | 585 | ); |
586 | 586 | } |
@@ -594,9 +594,9 @@ discard block |
||
594 | 594 | public function invalidateContainerCacheByPath(string $uri, int $siteId) |
595 | 595 | { |
596 | 596 | $cache = Craft::$app->getCache(); |
597 | - TagDependency::invalidate($cache, $this::METACONTAINER_CACHE_TAG.$uri.$siteId); |
|
597 | + TagDependency::invalidate($cache, $this::METACONTAINER_CACHE_TAG . $uri . $siteId); |
|
598 | 598 | Craft::info( |
599 | - 'Meta container cache cleared: '.$uri.'/'.$siteId, |
|
599 | + 'Meta container cache cleared: ' . $uri . '/' . $siteId, |
|
600 | 600 | __METHOD__ |
601 | 601 | ); |
602 | 602 | } |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | // Constants |
40 | 40 | // ========================================================================= |
41 | 41 | |
42 | - const SEOMATIC_SITEMAPINDEX_CONTAINER = Seomatic::SEOMATIC_HANDLE.SitemapIndexTemplate::TEMPLATE_TYPE; |
|
42 | + const SEOMATIC_SITEMAPINDEX_CONTAINER = Seomatic::SEOMATIC_HANDLE . SitemapIndexTemplate::TEMPLATE_TYPE; |
|
43 | 43 | |
44 | - const SEOMATIC_SITEMAP_CONTAINER = Seomatic::SEOMATIC_HANDLE.SitemapTemplate::TEMPLATE_TYPE; |
|
44 | + const SEOMATIC_SITEMAP_CONTAINER = Seomatic::SEOMATIC_HANDLE . SitemapTemplate::TEMPLATE_TYPE; |
|
45 | 45 | |
46 | 46 | const SEARCH_ENGINE_SUBMISSION_URLS = [ |
47 | 47 | 'google' => 'http://www.google.com/webmasters/sitemaps/ping?sitemap=', |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | Event::on( |
85 | 85 | UrlManager::class, |
86 | 86 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
87 | - function (RegisterUrlRulesEvent $event) { |
|
87 | + function(RegisterUrlRulesEvent $event) { |
|
88 | 88 | Craft::debug( |
89 | 89 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
90 | 90 | __METHOD__ |
@@ -103,18 +103,18 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function sitemapRouteRules(): array |
105 | 105 | { |
106 | - $rules = []; |
|
106 | + $rules = [ ]; |
|
107 | 107 | $groups = Craft::$app->getSites()->getAllGroups(); |
108 | - $groupId = $groups[0]->id; |
|
108 | + $groupId = $groups[ 0 ]->id; |
|
109 | 109 | $route = |
110 | 110 | Seomatic::$plugin->handle |
111 | 111 | .'/' |
112 | 112 | .'sitemap' |
113 | 113 | .'/' |
114 | 114 | .'sitemap-index'; |
115 | - $rules['sitemap.xml'] = [ |
|
115 | + $rules[ 'sitemap.xml' ] = [ |
|
116 | 116 | 'route' => $route, |
117 | - 'defaults' => ['groupId' => $groupId], |
|
117 | + 'defaults' => [ 'groupId' => $groupId ], |
|
118 | 118 | ]; |
119 | 119 | foreach ($this->sitemapTemplateContainer->data as $sitemapTemplate) { |
120 | 120 | /** @var $sitemapTemplate FrontendTemplate */ |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return string |
135 | 135 | */ |
136 | - public function renderTemplate(string $template, $params = []): string |
|
136 | + public function renderTemplate(string $template, $params = [ ]): string |
|
137 | 137 | { |
138 | 138 | $html = ''; |
139 | - if (!empty($this->sitemapTemplateContainer->data[$template])) { |
|
139 | + if (!empty($this->sitemapTemplateContainer->data[ $template ])) { |
|
140 | 140 | /** @var FrontendTemplate $sitemapTemplate */ |
141 | - $sitemapTemplate = $this->sitemapTemplateContainer->data[$template]; |
|
141 | + $sitemapTemplate = $this->sitemapTemplateContainer->data[ $template ]; |
|
142 | 142 | $html = $sitemapTemplate->render($params); |
143 | 143 | } |
144 | 144 | |
@@ -156,22 +156,22 @@ discard block |
||
156 | 156 | foreach ($searchEngineUrls as &$url) { |
157 | 157 | $groups = Craft::$app->getSites()->getAllGroups(); |
158 | 158 | foreach ($groups as $group) { |
159 | - $siteId = $group->getSiteIds()[0]; |
|
159 | + $siteId = $group->getSiteIds()[ 0 ]; |
|
160 | 160 | $sitemapIndexUrl = $this->sitemapIndexUrlForSiteId($siteId); |
161 | 161 | if (!empty($sitemapIndexUrl)) { |
162 | - $submissionUrl = $url.$sitemapIndexUrl; |
|
162 | + $submissionUrl = $url . $sitemapIndexUrl; |
|
163 | 163 | // create new guzzle client |
164 | - $guzzleClient = Craft::createGuzzleClient(['timeout' => 120, 'connect_timeout' => 120]); |
|
164 | + $guzzleClient = Craft::createGuzzleClient([ 'timeout' => 120, 'connect_timeout' => 120 ]); |
|
165 | 165 | // Submit the sitemap index to each search engine |
166 | 166 | try { |
167 | 167 | $guzzleClient->post($submissionUrl); |
168 | 168 | Craft::info( |
169 | - 'Sitemap index submitted to: '.$submissionUrl, |
|
169 | + 'Sitemap index submitted to: ' . $submissionUrl, |
|
170 | 170 | __METHOD__ |
171 | 171 | ); |
172 | 172 | } catch (\Exception $e) { |
173 | 173 | Craft::error( |
174 | - 'Error submitting sitemap index to: '.$submissionUrl.' - '.$e->getMessage(), |
|
174 | + 'Error submitting sitemap index to: ' . $submissionUrl . ' - ' . $e->getMessage(), |
|
175 | 175 | __METHOD__ |
176 | 176 | ); |
177 | 177 | } |
@@ -196,19 +196,19 @@ discard block |
||
196 | 196 | foreach ($searchEngineUrls as &$url) { |
197 | 197 | $sitemapUrl = $this->sitemapUrlForBundle($sourceBundleType, $sourceHandle, $sourceSiteId); |
198 | 198 | if (!empty($sitemapUrl)) { |
199 | - $submissionUrl = $url.$sitemapUrl; |
|
199 | + $submissionUrl = $url . $sitemapUrl; |
|
200 | 200 | // create new guzzle client |
201 | - $guzzleClient = Craft::createGuzzleClient(['timeout' => 120, 'connect_timeout' => 120]); |
|
201 | + $guzzleClient = Craft::createGuzzleClient([ 'timeout' => 120, 'connect_timeout' => 120 ]); |
|
202 | 202 | // Submit the sitemap index to each search engine |
203 | 203 | try { |
204 | 204 | $guzzleClient->post($submissionUrl); |
205 | 205 | Craft::info( |
206 | - 'Sitemap index submitted to: '.$submissionUrl, |
|
206 | + 'Sitemap index submitted to: ' . $submissionUrl, |
|
207 | 207 | __METHOD__ |
208 | 208 | ); |
209 | 209 | } catch (\Exception $e) { |
210 | 210 | Craft::error( |
211 | - 'Error submitting sitemap index to: '.$submissionUrl.' - '.$e->getMessage(), |
|
211 | + 'Error submitting sitemap index to: ' . $submissionUrl . ' - ' . $e->getMessage(), |
|
212 | 212 | __METHOD__ |
213 | 213 | ); |
214 | 214 | } |
@@ -310,9 +310,9 @@ discard block |
||
310 | 310 | public function invalidateSitemapCache(string $handle, int $siteId) |
311 | 311 | { |
312 | 312 | $cache = Craft::$app->getCache(); |
313 | - TagDependency::invalidate($cache, SitemapTemplate::SITEMAP_CACHE_TAG.$handle.$siteId); |
|
313 | + TagDependency::invalidate($cache, SitemapTemplate::SITEMAP_CACHE_TAG . $handle . $siteId); |
|
314 | 314 | Craft::info( |
315 | - 'Sitemap cache cleared: '.$handle, |
|
315 | + 'Sitemap cache cleared: ' . $handle, |
|
316 | 316 | __METHOD__ |
317 | 317 | ); |
318 | 318 | } |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @inheritdoc |
54 | 54 | */ |
55 | - public function create($config = [], $add = true): MetaJsonLd |
|
55 | + public function create($config = [ ], $add = true): MetaJsonLd |
|
56 | 56 | { |
57 | 57 | $type = self::DEFAULT_TYPE; |
58 | - if (!empty($config['type'])) { |
|
58 | + if (!empty($config[ 'type' ])) { |
|
59 | 59 | $type = ArrayHelper::remove($config, 'type'); |
60 | 60 | } |
61 | 61 | $metaItem = MetaJsonLd::create($type, $config); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function add($metaItem, string $handle = self::GENERAL_HANDLE): MetaJsonLd |
73 | 73 | { |
74 | - $key = MetaJsonLdContainer::CONTAINER_TYPE.$handle; |
|
74 | + $key = MetaJsonLdContainer::CONTAINER_TYPE . $handle; |
|
75 | 75 | Seomatic::$plugin->metaContainers->addToMetaContainer($metaItem, $key); |
76 | 76 | |
77 | 77 | /** @var MetaJsonLd $metaItem */ |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function container(string $handle = self::GENERAL_HANDLE) |
97 | 97 | { |
98 | - $key = MetaJsonLdContainer::CONTAINER_TYPE.$handle; |
|
98 | + $key = MetaJsonLdContainer::CONTAINER_TYPE . $handle; |
|
99 | 99 | |
100 | 100 | return Seomatic::$plugin->metaContainers->getMetaContainer($key); |
101 | 101 | } |