3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \Customer \Controller \Plugin ;
7
9
10
+ use Magento \Customer \Controller \AccountInterface ;
8
11
use Magento \Customer \Model \Session ;
9
12
use Magento \Framework \App \ActionInterface ;
10
13
use Magento \Framework \App \RequestInterface ;
11
14
use Magento \Framework \App \ResponseInterface ;
12
- use Magento \Framework \App \Action \AbstractAction ;
13
15
use Magento \Framework \Controller \ResultInterface ;
14
16
15
17
class Account
@@ -23,29 +25,35 @@ class Account
23
25
* @var array
24
26
*/
25
27
private $ allowedActions = [];
28
+ /**
29
+ * @var RequestInterface
30
+ */
31
+ private $ request ;
26
32
27
33
/**
34
+ * @param RequestInterface $request
28
35
* @param Session $customerSession
29
36
* @param array $allowedActions List of actions that are allowed for not authorized users
30
37
*/
31
38
public function __construct (
39
+ RequestInterface $ request ,
32
40
Session $ customerSession ,
33
41
array $ allowedActions = []
34
42
) {
35
43
$ this ->session = $ customerSession ;
36
44
$ this ->allowedActions = $ allowedActions ;
45
+ $ this ->request = $ request ;
37
46
}
38
47
39
48
/**
40
49
* Dispatch actions allowed for not authorized users
41
50
*
42
- * @param AbstractAction $subject
43
- * @param RequestInterface $request
51
+ * @param AccountInterface $subject
44
52
* @return void
45
53
*/
46
- public function beforeDispatch ( AbstractAction $ subject, RequestInterface $ request )
54
+ public function beforeExecute ( AccountInterface $ subject )
47
55
{
48
- $ action = strtolower ($ request ->getActionName ());
56
+ $ action = strtolower ($ this -> request ->getActionName ());
49
57
$ pattern = '/^( ' . implode ('| ' , $ this ->allowedActions ) . ')$/i ' ;
50
58
51
59
if (!preg_match ($ pattern , $ action )) {
@@ -60,13 +68,12 @@ public function beforeDispatch(AbstractAction $subject, RequestInterface $reques
60
68
/**
61
69
* Remove No-referer flag from customer session
62
70
*
63
- * @param AbstractAction $subject
71
+ * @param AccountInterface $subject
64
72
* @param ResponseInterface|ResultInterface $result
65
- * @param RequestInterface $request
66
73
* @return ResponseInterface|ResultInterface
67
74
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
68
75
*/
69
- public function afterDispatch ( AbstractAction $ subject , $ result, RequestInterface $ request )
76
+ public function afterExecute ( AccountInterface $ subject , $ result )
70
77
{
71
78
$ this ->session ->unsNoReferer (false );
72
79
return $ result ;
0 commit comments