File tree Expand file tree Collapse file tree 3 files changed +18
-15
lines changed
app/code/Magento/Newsletter/Controller/Subscriber Expand file tree Collapse file tree 3 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ class Confirm extends \Magento\Newsletter\Controller\Subscriber
10
10
{
11
11
/**
12
12
* Subscription confirm action
13
- * @return void
13
+ * @return \Magento\Framework\Controller\Result\Redirect
14
14
*/
15
15
public function execute ()
16
16
{
@@ -23,17 +23,17 @@ public function execute()
23
23
24
24
if ($ subscriber ->getId () && $ subscriber ->getCode ()) {
25
25
if ($ subscriber ->confirm ($ code )) {
26
- $ this ->messageManager ->addSuccess (__ ('Your subscription has been confirmed. ' ));
26
+ $ this ->messageManager ->addSuccessMessage (__ ('Your subscription has been confirmed. ' ));
27
27
} else {
28
- $ this ->messageManager ->addError (__ ('This is an invalid subscription confirmation code. ' ));
28
+ $ this ->messageManager ->addErrorMessage (__ ('This is an invalid subscription confirmation code. ' ));
29
29
}
30
30
} else {
31
- $ this ->messageManager ->addError (__ ('This is an invalid subscription ID. ' ));
31
+ $ this ->messageManager ->addErrorMessage (__ ('This is an invalid subscription ID. ' ));
32
32
}
33
33
}
34
-
35
- $ resultRedirect = $ this ->resultRedirectFactory ->create ();
36
- $ resultRedirect -> setUrl ( $ this ->_storeManager ->getStore ()->getBaseUrl () );
37
- return $ resultRedirect ;
34
+ /** @var \Magento\Framework\Controller\Result\Redirect $redirect */
35
+ $ redirect = $ this ->resultFactory ->create (\ Magento \ Framework \ Controller \ResultFactory:: TYPE_REDIRECT );
36
+ $ redirectUrl = $ this ->_storeManager ->getStore ()->getBaseUrl ();
37
+ return $ redirect -> setUrl ( $ redirectUrl ) ;
38
38
}
39
39
}
Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ protected function validateEmailFormat($email)
131
131
/**
132
132
* New subscription action
133
133
*
134
- * @return void
134
+ * @return \Magento\Framework\Controller\Result\Redirect
135
135
*/
136
136
public function execute ()
137
137
{
@@ -160,7 +160,10 @@ public function execute()
160
160
$ this ->messageManager ->addExceptionMessage ($ e , __ ('Something went wrong with the subscription. ' ));
161
161
}
162
162
}
163
- $ this ->getResponse ()->setRedirect ($ this ->_redirect ->getRedirectUrl ());
163
+ /** @var \Magento\Framework\Controller\Result\Redirect $redirect */
164
+ $ redirect = $ this ->resultFactory ->create (\Magento \Framework \Controller \ResultFactory::TYPE_REDIRECT );
165
+ $ redirectUrl = $ this ->_redirect ->getRedirectUrl ();
166
+ return $ redirect ->setUrl ($ redirectUrl );
164
167
}
165
168
166
169
/**
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ class Unsubscribe extends \Magento\Newsletter\Controller\Subscriber implements H
15
15
/**
16
16
* Unsubscribe newsletter.
17
17
*
18
- * @return \Magento\Backend\Model\View \Result\Redirect
18
+ * @return \Magento\Framework\Controller \Result\Redirect
19
19
*/
20
20
public function execute ()
21
21
{
@@ -25,14 +25,14 @@ public function execute()
25
25
if ($ id && $ code ) {
26
26
try {
27
27
$ this ->_subscriberFactory ->create ()->load ($ id )->setCheckCode ($ code )->unsubscribe ();
28
- $ this ->messageManager ->addSuccess (__ ('You unsubscribed. ' ));
28
+ $ this ->messageManager ->addSuccessMessage (__ ('You unsubscribed. ' ));
29
29
} catch (\Magento \Framework \Exception \LocalizedException $ e ) {
30
- $ this ->messageManager ->addException ($ e , $ e ->getMessage ());
30
+ $ this ->messageManager ->addErrorMessage ($ e , $ e ->getMessage ());
31
31
} catch (\Exception $ e ) {
32
- $ this ->messageManager ->addException ($ e , __ ('Something went wrong while unsubscribing you. ' ));
32
+ $ this ->messageManager ->addErrorMessage ($ e , __ ('Something went wrong while unsubscribing you. ' ));
33
33
}
34
34
}
35
- /** @var \Magento\Backend\Model\View \Result\Redirect $redirect */
35
+ /** @var \Magento\Framework\Controller \Result\Redirect $redirect */
36
36
$ redirect = $ this ->resultFactory ->create (\Magento \Framework \Controller \ResultFactory::TYPE_REDIRECT );
37
37
$ redirectUrl = $ this ->_redirect ->getRedirectUrl ();
38
38
return $ redirect ->setUrl ($ redirectUrl );
You can’t perform that action at this time.
0 commit comments