Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Action Class Reference
Inheritance diagram for Action:
Action AbstractAction ActionInterface Onepage Checkout Index Failure SaveOrder Success OnepageStub Addresses AddressesPost BackToAddresses BackToBilling BackToShipping Billing CheckItems Index Login Overview OverviewPost Register RemoveItem Shipping ShippingPost

Public Member Functions

 __construct (\Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, CustomerRepositoryInterface $customerRepository, AccountManagementInterface $accountManagement)
 
- Public Member Functions inherited from Action
 __construct (Context $context)
 
 dispatch (RequestInterface $request)
 
 getActionFlag ()
 
- Public Member Functions inherited from AbstractAction
 __construct (Context $context)
 
 dispatch (RequestInterface $request)
 
 getRequest ()
 
 getResponse ()
 
- Public Member Functions inherited from ActionInterface
 execute ()
 

Protected Member Functions

 _preDispatchValidateCustomer ($redirect=true, $addErrors=true)
 
- Protected Member Functions inherited from Action
 _forward ($action, $controller=null, $module=null, array $params=null)
 
 _redirect ($path, $arguments=[])
 

Protected Attributes

 $_customerSession
 
 $customerRepository
 
 $accountManagement
 
- Protected Attributes inherited from Action
 $_objectManager
 
 $_sessionNamespace
 
 $_eventManager
 
 $_actionFlag
 
 $_redirect
 
 $_view
 
 $_url
 
 $messageManager
 
- Protected Attributes inherited from AbstractAction
 $_request
 
 $_response
 
 $resultRedirectFactory
 
 $resultFactory
 

Additional Inherited Members

- Data Fields inherited from ActionInterface
const FLAG_NO_DISPATCH = 'no-dispatch'
 
const FLAG_NO_POST_DISPATCH = 'no-postDispatch'
 
const FLAG_NO_DISPATCH_BLOCK_EVENT = 'no-beforeGenerateLayoutBlocksDispatch'
 
const PARAM_NAME_BASE64_URL = 'r64'
 
const PARAM_NAME_URL_ENCODED = 'uenc'
 

Detailed Description

Controller for onepage checkouts

Definition at line 15 of file Action.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\App\Action\Context  $context,
\Magento\Customer\Model\Session  $customerSession,
CustomerRepositoryInterface  $customerRepository,
AccountManagementInterface  $accountManagement 
)
Parameters
\Magento\Framework\App\Action\Context$context
\Magento\Customer\Model\Session$customerSession
CustomerRepositoryInterface$customerRepository
AccountManagementInterface$accountManagement@codeCoverageIgnore

Definition at line 39 of file Action.php.

44  {
45  $this->_customerSession = $customerSession;
46  $this->customerRepository = $customerRepository;
47  $this->accountManagement = $accountManagement;
48  parent::__construct($context);
49  }

Member Function Documentation

◆ _preDispatchValidateCustomer()

_preDispatchValidateCustomer (   $redirect = true,
  $addErrors = true 
)
protected

Make sure customer is valid, if logged in

By default will add error messages and redirect to customer edit form

Parameters
bool$redirect- stop dispatch and redirect?
bool$addErrors- add error messages?
Returns
bool|\Magento\Framework\Controller\Result\Redirect

Definition at line 60 of file Action.php.

61  {
62  try {
63  $customer = $this->customerRepository->getById($this->_customerSession->getCustomerId());
64  } catch (NoSuchEntityException $e) {
65  return true;
66  }
67 
68  if (isset($customer)) {
69  $validationResult = $this->accountManagement->validate($customer);
70  if (!$validationResult->isValid()) {
71  if ($addErrors) {
72  foreach ($validationResult->getMessages() as $error) {
73  $this->messageManager->addErrorMessage($error);
74  }
75  }
76  if ($redirect) {
77  $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
78  return $this->resultRedirectFactory->create()->setPath('customer/account/edit');
79  }
80  return false;
81  }
82  }
83  return true;
84  }
$customer
Definition: customers.php:11

Field Documentation

◆ $_customerSession

$_customerSession
protected

Definition at line 20 of file Action.php.

◆ $accountManagement

$accountManagement
protected

Definition at line 30 of file Action.php.

◆ $customerRepository

$customerRepository
protected

Definition at line 25 of file Action.php.


The documentation for this class was generated from the following file: