當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RequestInterface::isAjax方法代碼示例

本文整理匯總了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;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:14,代碼來源:DepersonalizePlugin.php

示例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();
     }
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:13,代碼來源:CurrentCustomer.php

示例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 [];
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:64,代碼來源:Onepage.php

示例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;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:21,代碼來源:DepersonalizePlugin.php

示例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();
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:11,代碼來源:DepersonalizeChecker.php

示例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();
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:20,代碼來源:State.php


注:本文中的Magento\Framework\App\RequestInterface::isAjax方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。