Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
Public Member Functions | Protected Member Functions | Protected Attributes
Onepage Class Reference
Inheritance diagram for Onepage:
Action Action AbstractAction ActionInterface Index Failure SaveOrder Success OnepageStub

Public Member Functions

 __construct (\Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, CustomerRepositoryInterface $customerRepository, AccountManagementInterface $accountManagement, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\Translate\InlineInterface $translateInline, \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\View\LayoutFactory $layoutFactory, \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory)
 
 getOnepage ()
 
- Public Member Functions inherited from Action
 __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

 _ajaxRedirectResponse ()
 
 _expireAjax ()
 
 _getHtmlByHandle ($handle)
 
 _getShippingMethodsHtml ()
 
 _getPaymentMethodsHtml ()
 
 getProgressHtml ($checkoutStep='')
 
 _canShowForUnregisteredUsers ()
 
- Protected Member Functions inherited from Action
 _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

 $_sectionUpdateFunctions
 
 $_order
 
 $_coreRegistry = null
 
 $_translateInline
 
 $_formKeyValidator
 
 $scopeConfig
 
 $layoutFactory
 
 $quoteRepository
 
 $resultPageFactory
 
 $resultLayoutFactory
 
 $resultRawFactory
 
 $resultJsonFactory
 
- Protected Attributes inherited from Action
 $_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

@SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 16 of file Onepage.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\App\Action\Context  $context,
\Magento\Customer\Model\Session  $customerSession,
CustomerRepositoryInterface  $customerRepository,
AccountManagementInterface  $accountManagement,
\Magento\Framework\Registry  $coreRegistry,
\Magento\Framework\Translate\InlineInterface  $translateInline,
\Magento\Framework\Data\Form\FormKey\Validator  $formKeyValidator,
\Magento\Framework\App\Config\ScopeConfigInterface  $scopeConfig,
\Magento\Framework\View\LayoutFactory  $layoutFactory,
\Magento\Quote\Api\CartRepositoryInterface  $quoteRepository,
\Magento\Framework\View\Result\PageFactory  $resultPageFactory,
\Magento\Framework\View\Result\LayoutFactory  $resultLayoutFactory,
\Magento\Framework\Controller\Result\RawFactory  $resultRawFactory,
\Magento\Framework\Controller\Result\JsonFactory  $resultJsonFactory 
)
Parameters
\Magento\Framework\App\Action\Context$context
\Magento\Customer\Model\Session$customerSession
CustomerRepositoryInterface$customerRepository
AccountManagementInterface$accountManagement
\Magento\Framework\Registry$coreRegistry
\Magento\Framework\Translate\InlineInterface$translateInline
\Magento\Framework\Data\Form\FormKey\Validator$formKeyValidator
\Magento\Framework\App\Config\ScopeConfigInterface$scopeConfig
\Magento\Framework\View\LayoutFactory$layoutFactory
\Magento\Quote\Api\CartRepositoryInterface$quoteRepository
\Magento\Framework\View\Result\PageFactory$resultPageFactory
\Magento\Framework\View\Result\LayoutFactory$resultLayoutFactory
\Magento\Framework\Controller\Result\RawFactory$resultRawFactory
\Magento\Framework\Controller\Result\JsonFactory$resultJsonFactory@codeCoverageIgnore @SuppressWarnings(PHPMD.ExcessiveParameterList)

Definition at line 103 of file Onepage.php.

118  {
119  $this->_coreRegistry = $coreRegistry;
120  $this->_translateInline = $translateInline;
121  $this->_formKeyValidator = $formKeyValidator;
122  $this->scopeConfig = $scopeConfig;
123  $this->layoutFactory = $layoutFactory;
124  $this->quoteRepository = $quoteRepository;
125  $this->resultPageFactory = $resultPageFactory;
126  $this->resultLayoutFactory = $resultLayoutFactory;
127  $this->resultRawFactory = $resultRawFactory;
128  $this->resultJsonFactory = $resultJsonFactory;
129  parent::__construct(
130  $context,
131  $customerSession,
134  );
135  }

Member Function Documentation

◆ _ajaxRedirectResponse()

_ajaxRedirectResponse ( )
protected
Returns
\Magento\Framework\Controller\Result\Raw

Definition at line 167 of file Onepage.php.

168  {
169  $resultRaw = $this->resultRawFactory->create();
170  $resultRaw->setStatusHeader(403, '1.1', 'Session Expired')
171  ->setHeader('Login-Required', 'true');
172  return $resultRaw;
173  }

◆ _canShowForUnregisteredUsers()

_canShowForUnregisteredUsers ( )
protected

Check can page show for unregistered users

Returns
boolean

Definition at line 269 of file Onepage.php.

270  {
271  return $this->_objectManager->get(
272  \Magento\Customer\Model\Session::class
273  )->isLoggedIn() || $this->getRequest()->getActionName() == 'index' || $this->_objectManager->get(
274  \Magento\Checkout\Helper\Data::class
275  )->isAllowedGuestCheckout(
276  $this->getOnepage()->getQuote()
277  ) || !$this->_objectManager->get(
278  \Magento\Checkout\Helper\Data::class
279  )->isCustomerMustBeLogged();
280  }

◆ _expireAjax()

_expireAjax ( )
protected

Validate ajax request and redirect on failure

Returns
bool

Definition at line 180 of file Onepage.php.

181  {
182  $quote = $this->getOnepage()->getQuote();
183  if (!$quote->hasItems() || $quote->getHasError() || !$quote->validateMinimumAmount()) {
184  return true;
185  }
186  $action = $this->getRequest()->getActionName();
187  if ($this->_objectManager->get(\Magento\Checkout\Model\Session::class)->getCartWasUpdated(true)
188  &&
189  !in_array($action, ['index', 'progress'])
190  ) {
191  return true;
192  }
193 
194  return false;
195  }
$quote

◆ _getHtmlByHandle()

_getHtmlByHandle (   $handle)
protected

Render HTML based on requested layout handle name

Parameters
string$handle
Returns
string

Definition at line 203 of file Onepage.php.

204  {
205  $layout = $this->layoutFactory->create();
206  $layout->getUpdate()->load([$handle]);
207  $layout->generateXml();
208  $layout->generateElements();
209  $output = $layout->getOutput();
210  $this->_translateInline->processResponseBody($output);
211  return $output;
212  }
$handle

◆ _getPaymentMethodsHtml()

_getPaymentMethodsHtml ( )
protected

Get payment method step html

Returns
string @codeCoverageIgnore

Definition at line 231 of file Onepage.php.

232  {
233  return $this->_getHtmlByHandle('checkout_onepage_paymentmethod');
234  }

◆ _getShippingMethodsHtml()

_getShippingMethodsHtml ( )
protected

Get shipping method step html

Returns
string @codeCoverageIgnore

Definition at line 220 of file Onepage.php.

221  {
222  return $this->_getHtmlByHandle('checkout_onepage_shippingmethod');
223  }

◆ getOnepage()

getOnepage ( )

Get one page checkout model

Returns
\Magento\Checkout\Model\Type\Onepage @codeCoverageIgnore

Definition at line 259 of file Onepage.php.

260  {
261  return $this->_objectManager->get(\Magento\Checkout\Model\Type\Onepage::class);
262  }

◆ getProgressHtml()

getProgressHtml (   $checkoutStep = '')
protected

Get progress html checkout step

Parameters
string$checkoutStep
Returns
mixed

Definition at line 242 of file Onepage.php.

243  {
244  $layout = $this->layoutFactory->create();
245  $layout->getUpdate()->load(['checkout_onepage_progress']);
246  $layout->generateXml();
247  $layout->generateElements();
248 
249  $block = $layout->getBlock('progress')->setAttribute('next_step', $checkoutStep);
250  return $block->toHtml();
251  }
$block
Definition: block.php:8

Field Documentation

◆ $_coreRegistry

$_coreRegistry = null
protected

Definition at line 37 of file Onepage.php.

◆ $_formKeyValidator

$_formKeyValidator
protected

Definition at line 47 of file Onepage.php.

◆ $_order

$_order
protected

Definition at line 30 of file Onepage.php.

◆ $_sectionUpdateFunctions

$_sectionUpdateFunctions
protected
Initial value:
= [
'payment-method' => '_getPaymentMethodsHtml',
'shipping-method' => '_getShippingMethodsHtml',
'review' => '_getReviewHtml',
]

Definition at line 21 of file Onepage.php.

◆ $_translateInline

$_translateInline
protected

Definition at line 42 of file Onepage.php.

◆ $layoutFactory

$layoutFactory
protected

Definition at line 57 of file Onepage.php.

◆ $quoteRepository

$quoteRepository
protected

Definition at line 62 of file Onepage.php.

◆ $resultJsonFactory

$resultJsonFactory
protected

Definition at line 82 of file Onepage.php.

◆ $resultLayoutFactory

$resultLayoutFactory
protected

Definition at line 72 of file Onepage.php.

◆ $resultPageFactory

$resultPageFactory
protected

Definition at line 67 of file Onepage.php.

◆ $resultRawFactory

$resultRawFactory
protected

Definition at line 77 of file Onepage.php.

◆ $scopeConfig

$scopeConfig
protected

Definition at line 52 of file Onepage.php.


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