@@ -96,39 +96,41 @@ public function __construct(
96
96
*/
97
97
public function switch (StoreInterface $ fromStore , StoreInterface $ targetStore , string $ redirectUrl ): string
98
98
{
99
- $ timestamp = (int ) $ this ->request ->getParam ('time_stamp ' );
100
- $ signature = (string ) $ this ->request ->getParam ('signature ' );
101
- $ data = (string ) $ this ->request ->getParam ('data ' );
102
- $ context = $ this ->contextFactory ->create (
103
- [
104
- 'fromStore ' => $ fromStore ,
105
- 'targetStore ' => $ targetStore ,
106
- 'redirectUrl ' => $ redirectUrl
107
- ]
108
- );
109
- $ redirectDataObject = $ this ->dataFactory ->create (
110
- [
111
- 'signature ' => $ signature ,
112
- 'timestamp ' => $ timestamp ,
113
- 'data ' => $ data
114
- ]
115
- );
99
+ if ($ this ->request ->getParam ('data ' ) !== null ) {
100
+ $ timestamp = (int ) $ this ->request ->getParam ('time_stamp ' );
101
+ $ signature = (string ) $ this ->request ->getParam ('signature ' );
102
+ $ data = (string ) $ this ->request ->getParam ('data ' );
103
+ $ context = $ this ->contextFactory ->create (
104
+ [
105
+ 'fromStore ' => $ fromStore ,
106
+ 'targetStore ' => $ targetStore ,
107
+ 'redirectUrl ' => $ redirectUrl
108
+ ]
109
+ );
110
+ $ redirectDataObject = $ this ->dataFactory ->create (
111
+ [
112
+ 'signature ' => $ signature ,
113
+ 'timestamp ' => $ timestamp ,
114
+ 'data ' => $ data
115
+ ]
116
+ );
116
117
117
- try {
118
- if ($ redirectUrl && $ this ->dataValidator ->validate ($ context , $ redirectDataObject )) {
119
- $ this ->postprocessor ->process ($ context , $ this ->dataSerializer ->unserialize ($ data ));
120
- } else {
121
- throw new LocalizedException (
122
- __ ('The requested store cannot be found. Please check the request and try again. ' )
118
+ try {
119
+ if ($ redirectUrl && $ this ->dataValidator ->validate ($ context , $ redirectDataObject )) {
120
+ $ this ->postprocessor ->process ($ context , $ this ->dataSerializer ->unserialize ($ data ));
121
+ } else {
122
+ throw new LocalizedException (
123
+ __ ('The requested store cannot be found. Please check the request and try again. ' )
124
+ );
125
+ }
126
+ } catch (LocalizedException $ exception ) {
127
+ $ this ->messageManager ->addErrorMessage ($ exception ->getMessage ());
128
+ } catch (\Throwable $ exception ) {
129
+ $ this ->logger ->error ($ exception );
130
+ $ this ->messageManager ->addErrorMessage (
131
+ __ ('Something went wrong. ' )
123
132
);
124
133
}
125
- } catch (LocalizedException $ exception ) {
126
- $ this ->messageManager ->addErrorMessage ($ exception ->getMessage ());
127
- } catch (\Throwable $ exception ) {
128
- $ this ->logger ->error ($ exception );
129
- $ this ->messageManager ->addErrorMessage (
130
- __ ('Something went wrong. ' )
131
- );
132
134
}
133
135
134
136
return $ redirectUrl ;
0 commit comments