Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Account.php
Go to the documentation of this file.
1 <?php
7 
14 
15 class Account
16 {
20  protected $session;
21 
25  private $allowedActions = [];
26 
31  public function __construct(
32  Session $customerSession,
33  array $allowedActions = []
34  ) {
35  $this->session = $customerSession;
36  $this->allowedActions = $allowedActions;
37  }
38 
47  {
48  $action = strtolower($request->getActionName());
49  $pattern = '/^(' . implode('|', $this->allowedActions) . ')$/i';
50 
51  if (!preg_match($pattern, $action)) {
52  if (!$this->session->authenticate()) {
53  $subject->getActionFlag()->set('', ActionInterface::FLAG_NO_DISPATCH, true);
54  }
55  } else {
56  $this->session->setNoReferer(true);
57  }
58  }
59 
70  {
71  $this->session->unsNoReferer(false);
72  return $result;
73  }
74 }
$pattern
Definition: website.php:22
__construct(Session $customerSession, array $allowedActions=[])
Definition: Account.php:31
beforeDispatch(AbstractAction $subject, RequestInterface $request)
Definition: Account.php:46
afterDispatch(AbstractAction $subject, $result, RequestInterface $request)
Definition: Account.php:69