@@ -552,27 +552,11 @@ private function initScope()
552
552
$ this ->setSection ('' );
553
553
}
554
554
555
- if (!$ this ->getScope ()) {
556
- switch (true ) {
557
- case $ this ->getStore ():
558
- $ this ->setScope (StoreScopeInterface::SCOPE_STORES );
559
- $ this ->setScopeCode ($ this ->getStore ());
560
- break ;
561
- case $ this ->getWebsite ():
562
- $ this ->setScope (StoreScopeInterface::SCOPE_WEBSITES );
563
- $ this ->setScopeCode ($ this ->getWebsite ());
564
- break ;
565
- default :
566
- $ this ->setScope (ScopeInterface::SCOPE_DEFAULT );
567
- $ this ->setScopeCode ('' );
568
- break ;
569
- }
570
- }
571
- $ scope = $ this ->scopeResolverPool ->get ($ this ->getScope ())
572
- ->getScope ($ this ->getScopeCode ());
555
+ $ scope = $ this ->retrieveScope ();
573
556
$ this ->setScope ($ this ->scopeTypeNormalizer ->normalize ($ scope ->getScopeType ()));
574
557
$ this ->setScopeCode ($ scope ->getCode ());
575
558
$ this ->setScopeId ($ scope ->getId ());
559
+
576
560
if ($ this ->getWebsite () === null ) {
577
561
$ this ->setWebsite (StoreScopeInterface::SCOPE_WEBSITES === $ this ->getScope () ? $ scope ->getId () : '' );
578
562
}
@@ -581,6 +565,54 @@ private function initScope()
581
565
}
582
566
}
583
567
568
+ /**
569
+ * Retrieve scope from initial data
570
+ *
571
+ * @return ScopeInterface
572
+ */
573
+ private function retrieveScope (): ScopeInterface
574
+ {
575
+ $ scopeType = $ this ->getScope ();
576
+ if (!$ scopeType ) {
577
+ switch (true ) {
578
+ case $ this ->getStore ():
579
+ $ scopeType = StoreScopeInterface::SCOPE_STORES ;
580
+ $ scopeIdentifier = $ this ->getStore ();
581
+ break ;
582
+ case $ this ->getWebsite ():
583
+ $ scopeType = StoreScopeInterface::SCOPE_WEBSITES ;
584
+ $ scopeIdentifier = $ this ->getWebsite ();
585
+ break ;
586
+ default :
587
+ $ scopeType = ScopeInterface::SCOPE_DEFAULT ;
588
+ $ scopeIdentifier = null ;
589
+ break ;
590
+ }
591
+ } else {
592
+ switch (true ) {
593
+ case $ this ->getScopeId () !== null :
594
+ $ scopeIdentifier = $ this ->getScopeId ();
595
+ break ;
596
+ case $ this ->getScopeCode () !== null :
597
+ $ scopeIdentifier = $ this ->getScopeCode ();
598
+ break ;
599
+ case $ this ->getStore () !== null :
600
+ $ scopeIdentifier = $ this ->getStore ();
601
+ break ;
602
+ case $ this ->getWebsite () !== null :
603
+ $ scopeIdentifier = $ this ->getWebsite ();
604
+ break ;
605
+ default :
606
+ $ scopeIdentifier = null ;
607
+ break ;
608
+ }
609
+ }
610
+ $ scope = $ this ->scopeResolverPool ->get ($ scopeType )
611
+ ->getScope ($ scopeIdentifier );
612
+
613
+ return $ scope ;
614
+ }
615
+
584
616
/**
585
617
* Return formatted config data for current section
586
618
*
0 commit comments