@@ -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::strictMerge( |
@@ -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::strictMerge( |
@@ -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::strictMerge( |
@@ -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; |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | // Remove any empty keys from our file-based config |
796 | 796 | $metaBundleDefaults = ArrayHelper::arrayFilterRecursive( |
797 | 797 | $metaBundleDefaults, |
798 | - [ArrayHelper::class, 'unsetEmptyChildren'] |
|
798 | + [ ArrayHelper::class, 'unsetEmptyChildren' ] |
|
799 | 799 | ); |
800 | 800 | // Merge them together |
801 | 801 | $metaBundle = MetaBundle::create(ArrayHelper::strictMerge( |
@@ -49,19 +49,19 @@ discard block |
||
49 | 49 | while (!empty($args)) { |
50 | 50 | foreach (array_shift($args) as $k => $v) { |
51 | 51 | if ($v instanceof UnsetArrayValue) { |
52 | - unset($res[$k]); |
|
52 | + unset($res[ $k ]); |
|
53 | 53 | } elseif ($v instanceof ReplaceArrayValue) { |
54 | - $res[$k] = $v->value; |
|
54 | + $res[ $k ] = $v->value; |
|
55 | 55 | } elseif (is_int($k)) { |
56 | 56 | if (array_key_exists($k, $res)) { |
57 | - $res[] = $v; |
|
57 | + $res[ ] = $v; |
|
58 | 58 | } else { |
59 | - $res[$k] = $v; |
|
59 | + $res[ $k ] = $v; |
|
60 | 60 | } |
61 | - } elseif (is_array($v) && isset($res[$k]) && is_array($res[$k])) { |
|
62 | - $res[$k] = self::merge($res[$k], $v); |
|
61 | + } elseif (is_array($v) && isset($res[ $k ]) && is_array($res[ $k ])) { |
|
62 | + $res[ $k ] = self::merge($res[ $k ], $v); |
|
63 | 63 | } else { |
64 | - $res[$k] = $v; |
|
64 | + $res[ $k ] = $v; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | } |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | { |
90 | 90 | foreach ($array as $k => $v) { |
91 | 91 | if (is_array($v)) { |
92 | - $array[$k] = self::arrayFilterRecursive($v, $callback); |
|
92 | + $array[ $k ] = self::arrayFilterRecursive($v, $callback); |
|
93 | 93 | } else { |
94 | 94 | if ($callback($v, $k)) { |
95 | - unset($array[$k]); |
|
95 | + unset($array[ $k ]); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |