File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed
app/code/Magento/StoreGraphQl/Controller/HttpRequestValidator Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -42,14 +42,30 @@ public function validate(HttpRequestInterface $request): void
42
42
{
43
43
$ headerValue = $ request ->getHeader ('Store ' );
44
44
if (!empty ($ headerValue )) {
45
- $ storeCode = ltrim (rtrim ($ headerValue ));
46
- $ stores = $ this ->storeManager ->getStores (false , true );
47
- if ((!isset ($ stores [$ storeCode ]) && strtolower ($ storeCode ) !== 'default ' )
48
- || !$ stores [$ storeCode ]->getIsActive ()
49
- ) {
45
+ $ storeCode = trim ($ headerValue );
46
+ if (!$ this ->isStoreActive ($ storeCode )) {
50
47
$ this ->storeManager ->setCurrentStore (null );
51
48
throw new GraphQlInputException (__ ('Requested store is not found ' ));
52
49
}
53
50
}
54
51
}
52
+
53
+ /**
54
+ * Check if provided store code corresponds to an active store
55
+ *
56
+ * @param string $storeCode
57
+ * @return bool
58
+ */
59
+ private function isStoreActive (string $ storeCode ): bool
60
+ {
61
+ $ stores = $ this ->storeManager ->getStores (false , true );
62
+ if (strtolower ($ storeCode ) === 'default ' ) {
63
+ return true ;
64
+ }
65
+ if (isset ($ stores [$ storeCode ])) {
66
+ return (bool )$ stores [$ storeCode ]->getIsActive ();
67
+ }
68
+
69
+ return false ;
70
+ }
55
71
}
You can’t perform that action at this time.
0 commit comments