本文整理汇总了PHP中Magento\Framework\App\RequestInterface::isAjax方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::isAjax方法的具体用法?PHP RequestInterface::isAjax怎么用?PHP RequestInterface::isAjax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::isAjax方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterGenerateXml
/**
* After generate Xml
*
* @param \Magento\Framework\View\LayoutInterface $subject
* @param \Magento\Framework\View\LayoutInterface $result
* @return \Magento\Framework\View\LayoutInterface
*/
public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result)
{
if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && !$this->request->isAjax() && $subject->isCacheable()) {
$this->checkoutSession->clearStorage();
}
return $result;
}
示例2: getCustomer
/**
* Returns current customer according to session and context
*
* @return \Magento\Customer\Service\V1\Data\Customer
*/
public function getCustomer()
{
if ($this->moduleManager->isEnabled('Magento_PageCache') && !$this->request->isAjax() && $this->view->isLayoutLoaded() && $this->layout->isCacheable()) {
return $this->getDepersonalizedCustomer();
} else {
return $this->getCustomerFromService();
}
}
示例3: saveShipping
/**
* Save checkout shipping address
*
* @param array $data
* @param int $customerAddressId
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function saveShipping($data, $customerAddressId)
{
if (empty($data)) {
return ['error' => -1, 'message' => __('Invalid data')];
}
$address = $this->getQuote()->getShippingAddress();
$addressForm = $this->_formFactory->create('customer_address', 'customer_address_edit', [], $this->_request->isAjax(), Form::IGNORE_INVISIBLE, []);
if (!empty($customerAddressId)) {
$addressData = null;
try {
$addressData = $this->addressRepository->getById($customerAddressId);
} catch (NoSuchEntityException $e) {
// do nothing if customer is not found by id
}
if ($addressData->getCustomerId() != $this->getQuote()->getCustomerId()) {
return ['error' => 1, 'message' => __('The customer address is not valid.')];
}
$address->importCustomerAddressData($addressData)->setSaveInAddressBook(0);
$addressErrors = $addressForm->validateData($address->getData());
if ($addressErrors !== true) {
return ['error' => 1, 'message' => $addressErrors];
}
} else {
// emulate request object
$addressData = $addressForm->extractData($addressForm->prepareRequest($data));
$addressErrors = $addressForm->validateData($addressData);
if ($addressErrors !== true) {
return ['error' => 1, 'message' => $addressErrors];
}
$compactedData = $addressForm->compactData($addressData);
// unset shipping address attributes which were not shown in form
foreach ($addressForm->getAttributes() as $attribute) {
$attributeCode = $attribute->getAttributeCode();
if (!isset($data[$attributeCode])) {
$address->setData($attributeCode, null);
} else {
if (isset($compactedData[$attributeCode])) {
$address->setDataUsingMethod($attributeCode, $compactedData[$attributeCode]);
}
}
}
$address->setCustomerAddressId(null);
// Additional form data, not fetched by extractData (as it fetches only attributes)
$address->setSaveInAddressBook(empty($data['save_in_address_book']) ? 0 : 1);
$address->setSameAsBilling(empty($data['same_as_billing']) ? 0 : 1);
}
$address->setCollectShippingRates(true);
if (($validateRes = $address->validate()) !== true) {
return ['error' => 1, 'message' => $validateRes];
}
$this->totalsCollector->collectAddressTotals($this->getQuote(), $address);
$address->save();
$this->getCheckout()->setStepData('shipping', 'complete', true)->setStepData('shipping_method', 'allow', true);
return [];
}
示例4: afterGenerateXml
/**
* After generate Xml
*
* @param \Magento\Framework\View\LayoutInterface $subject
* @param \Magento\Framework\View\LayoutInterface $result
* @return \Magento\Framework\View\LayoutInterface
*/
public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result)
{
if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && !$this->request->isAjax() && $subject->isCacheable()) {
$this->visitor->setSkipRequestLogging(true);
$this->visitor->unsetData();
$this->session->clearStorage();
$this->customerSession->clearStorage();
$this->session->setData(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $this->formKey);
$this->customerSession->setCustomerGroupId($this->customerGroupId);
$this->customer->setGroupId($this->customerGroupId);
$this->customerSession->setCustomer($this->customer);
}
return $result;
}
示例5: checkIfDepersonalize
/**
* Check if depersonalize or not
*
* @param \Magento\Framework\View\LayoutInterface $subject
* @return bool
* @api
*/
public function checkIfDepersonalize(\Magento\Framework\View\LayoutInterface $subject)
{
return $this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && !$this->request->isAjax() && ($this->request->isGet() || $this->request->isHead()) && $subject->isCacheable();
}
示例6: update
/**
* Update system data for current VDE environment
*
* @param string $areaCode
* @param \Magento\Framework\App\RequestInterface $request
* @return void
*/
public function update($areaCode, \Magento\Framework\App\RequestInterface $request)
{
$mode = $request->getAlias('editorMode') ?: self::MODE_NAVIGATION;
$this->_themeContext->setEditableThemeById($request->getAlias('themeId'));
if (!$request->isAjax()) {
$this->_backendSession->setData(self::CURRENT_URL_SESSION_KEY, $request->getPathInfo());
$this->_backendSession->setData(self::CURRENT_MODE_SESSION_KEY, $mode);
}
$this->_injectUrlModel($mode);
$this->_emulateArea($mode, $areaCode);
$this->_setTheme();
$this->_disableCache();
}