当前位置: 首页>>代码示例>>PHP>>正文


PHP State::getAreaCode方法代码示例

本文整理汇总了PHP中Magento\Framework\App\State::getAreaCode方法的典型用法代码示例。如果您正苦于以下问题:PHP State::getAreaCode方法的具体用法?PHP State::getAreaCode怎么用?PHP State::getAreaCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\App\State的用法示例。


在下文中一共展示了State::getAreaCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load

 /**
  * Load design
  *
  * @return void
  */
 public function load()
 {
     $area = $this->_areaList->getArea($this->appState->getAreaCode());
     $area->load(\Magento\Framework\App\Area::PART_DESIGN);
     $area->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     $area->detectDesign($this->_request);
 }
开发者ID:,项目名称:,代码行数:12,代码来源:

示例2: build

 /**
  * @param array $buildSubject
  * @return mixed
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $payment = $paymentDataObject->getPayment();
     $order = $paymentDataObject->getOrder();
     $storeId = $order->getStoreId();
     $request = [];
     if ($this->adyenHelper->getAdyenCcConfigDataFlag('cse_enabled', $storeId)) {
         $request['additionalData']['card.encrypted.json'] = $payment->getAdditionalInformation("encrypted_data");
     } else {
         $requestCreditCardDetails = ["expiryMonth" => $payment->getCcExpMonth(), "expiryYear" => $payment->getCcExpYear(), "holderName" => $payment->getCcOwner(), "number" => $payment->getCcNumber(), "cvc" => $payment->getCcCid()];
         $cardDetails['card'] = $requestCreditCardDetails;
         $request = array_merge($request, $cardDetails);
     }
     /**
      * if MOTO for backend is enabled use MOTO as shopper interaction type
      */
     $enableMoto = $this->adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $storeId);
     if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE && $enableMoto) {
         $request['shopperInteraction'] = "Moto";
     }
     // if installments is set add it into the request
     if ($payment->getAdditionalInformation('number_of_installments') && $payment->getAdditionalInformation('number_of_installments') > 0) {
         $request['installments']['value'] = $payment->getAdditionalInformation('number_of_installments');
     }
     return $request;
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:32,代码来源:CcAuthorizationDataBuilder.php

示例3: testEmulateAreaCodeException

 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Some error
  */
 public function testEmulateAreaCodeException()
 {
     $areaCode = 'original code';
     $emulatedCode = 'emulated code';
     $this->scopeMock->expects($this->once())->method('setCurrentScope')->with($areaCode);
     $this->model->setAreaCode($areaCode);
     $this->model->emulateAreaCode($emulatedCode, [$this, 'emulateAreaCodeCallbackException']);
     $this->assertEquals($this->model->getAreaCode(), $areaCode);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:13,代码来源:StateTest.php

示例4: beforeDispatch

 /**
  * @param AbstractAction $subject
  * @param RequestInterface $request
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeDispatch(AbstractAction $subject, RequestInterface $request)
 {
     if ($this->state->getAreaCode() == Area::AREA_FRONTEND && $request->isPost() && $this->notificationStorage->isExists(NotificationStorage::UPDATE_CUSTOMER_SESSION, $this->session->getCustomerId())) {
         $customer = $this->customerRepository->getById($this->session->getCustomerId());
         $this->session->setCustomerData($customer);
         $this->session->setCustomerGroupId($customer->getGroupId());
         $this->session->regenerateId();
         $this->notificationStorage->remove(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customer->getId());
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:CustomerNotification.php

示例5: isFrontendArea

 /**
  * @return bool
  */
 public function isFrontendArea()
 {
     try {
         if ($this->state->getAreaCode() == Area::AREA_ADMINHTML) {
             return false;
         }
     } catch (LocalizedException $e) {
         /* Area is not initialized. Do nothing. */
         return true;
     }
     return true;
 }
开发者ID:ytorbyk,项目名称:magento2-geo-store-switcher,代码行数:15,代码来源:AppState.php

示例6: getData

 /**
  * Get translation data
  *
  * @param string $themePath
  * @return string[]
  * @throws \Exception
  * @throws \Magento\Framework\Exception
  */
 public function getData($themePath)
 {
     $dictionary = [];
     $files = $this->filesUtility->getJsFiles($this->appState->getAreaCode(), $themePath);
     foreach ($files as $filePath) {
         $content = $this->rootDirectory->readFile($this->rootDirectory->getRelativePath($filePath[0]));
         foreach ($this->getPhrases($content) as $phrase) {
             $translatedPhrase = (string) __($phrase);
             if ($phrase != $translatedPhrase) {
                 $dictionary[$phrase] = $translatedPhrase;
             }
         }
     }
     return $dictionary;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:23,代码来源:DataProvider.php

示例7: processAjaxPost

 /**
  * Parse and save edited translation
  *
  * @param array $translateParams
  * @return array
  */
 public function processAjaxPost(array $translateParams)
 {
     if (!$this->_translateInline->isAllowed()) {
         return ['inline' => 'not allowed'];
     }
     $this->_appCache->invalidate(\Magento\Framework\App\Cache\Type\Translate::TYPE_IDENTIFIER);
     $this->_validateTranslationParams($translateParams);
     $this->_filterTranslationParams($translateParams, ['custom']);
     /** @var $validStoreId int */
     $validStoreId = $this->_storeManager->getStore()->getId();
     /** @var $resource \Magento\Translation\Model\ResourceModel\StringUtils */
     $resource = $this->_resourceFactory->create();
     foreach ($translateParams as $param) {
         if ($this->_appState->getAreaCode() == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
             $storeId = 0;
         } else {
             if (empty($param['perstore'])) {
                 $resource->deleteTranslate($param['original'], null, false);
                 $storeId = 0;
             } else {
                 $storeId = $validStoreId;
             }
         }
         $resource->saveTranslate($param['original'], $param['custom'], null, $storeId);
     }
     return $this->getCacheManger()->updateAndGetTranslations();
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:33,代码来源:Parser.php

示例8: dispatch

 /**
  * Handle REST request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $path = $this->_pathProcessor->process($request->getPathInfo());
     $this->_request->setPathInfo($path);
     $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     try {
         $this->checkPermissions();
         $route = $this->getCurrentRoute();
         if ($route->isSecure() && !$this->_request->isSecure()) {
             throw new \Magento\Webapi\Exception(__('Operation allowed only in HTTPS'));
         }
         /** @var array $inputData */
         $inputData = $this->_request->getRequestData();
         $serviceMethodName = $route->getServiceMethod();
         $serviceClassName = $route->getServiceClass();
         $inputData = $this->overrideParams($inputData, $route->getParameters());
         $inputParams = $this->_serializer->getInputData($serviceClassName, $serviceMethodName, $inputData);
         $service = $this->_objectManager->get($serviceClassName);
         /** @var \Magento\Framework\Service\Data\AbstractExtensibleObject $outputData */
         $outputData = call_user_func_array([$service, $serviceMethodName], $inputParams);
         $outputData = $this->dataObjectConverter->processServiceOutput($outputData);
         if ($this->_request->getParam(PartialResponseProcessor::FILTER_PARAMETER) && is_array($outputData)) {
             $outputData = $this->partialResponseProcessor->filter($outputData);
         }
         $this->_response->prepareResponse($outputData);
     } catch (\Exception $e) {
         $maskedException = $this->_errorProcessor->maskException($e);
         $this->_response->setException($maskedException);
     }
     return $this->_response;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:37,代码来源:Rest.php

示例9: getAdyenOneclickPaymentMethods

 public function getAdyenOneclickPaymentMethods()
 {
     $billingAgreements = [];
     if ($this->_customerSession->isLoggedIn()) {
         $customerId = $this->_customerSession->getCustomerId();
         // is admin?
         if ($this->_appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
             //retrieve storeId from quote
             $store = $this->_session->getQuote()->getStore();
         } else {
             $store = $this->_storeManager->getStore();
         }
         $baCollection = $this->_billingAgreementCollectionFactory->create();
         $baCollection->addFieldToFilter('customer_id', $customerId);
         $baCollection->addFieldToFilter('store_id', $store->getId());
         $baCollection->addFieldToFilter('method_code', 'adyen_oneclick');
         $baCollection->addActiveFilter();
         $recurringPaymentType = $this->_getRecurringContractType();
         foreach ($baCollection as $billingAgreement) {
             $agreementData = $billingAgreement->getAgreementData();
             // check if AgreementLabel is set and if contract has an recurringType
             if ($billingAgreement->getAgreementLabel()) {
                 $data = ['reference_id' => $billingAgreement->getReferenceId(), 'agreement_label' => $billingAgreement->getAgreementLabel(), 'agreement_data' => $agreementData];
                 $billingAgreements[] = $data;
             }
         }
     }
     return $billingAgreements;
 }
开发者ID:pivulic,项目名称:adyen-magento2,代码行数:29,代码来源:AdyenOneclickConfigProvider.php

示例10: getArea

 /**
  * Retrieve package area
  *
  * @return string
  */
 public function getArea()
 {
     // In order to support environment emulation of area, if area is set, return it
     if ($this->_area && !$this->_appState->isAreaCodeEmulated()) {
         return $this->_area;
     }
     return $this->_appState->getAreaCode();
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:13,代码来源:Design.php

示例11: get

 /**
  * Retrieve instance of a theme currently used in an area
  *
  * @return \Magento\Framework\View\Design\ThemeInterface
  */
 public function get()
 {
     $area = $this->appState->getAreaCode();
     if ($this->design->getDesignTheme()->getArea() == $area || $this->design->getArea() == $area) {
         return $this->design->getDesignTheme();
     }
     /** @var \Magento\Theme\Model\ResourceModel\Theme\Collection $themeCollection */
     $themeCollection = $this->themeFactory->create();
     $themeIdentifier = $this->design->getConfigurationDesignTheme($area);
     if (is_numeric($themeIdentifier)) {
         $result = $themeCollection->getItemById($themeIdentifier);
     } else {
         $themeFullPath = $area . \Magento\Framework\View\Design\ThemeInterface::PATH_SEPARATOR . $themeIdentifier;
         $result = $themeCollection->getThemeByFullPath($themeFullPath);
     }
     return $result;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:22,代码来源:Resolver.php

示例12: execute

 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @return null|int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     try {
         $area = $this->appState->getAreaCode();
         if ($area != Area::AREA_ADMINHTML) {
             $this->appState->setAreaCode(Area::AREA_ADMINHTML);
         }
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $this->appState->setAreaCode(Area::AREA_ADMINHTML);
     }
     $area = $this->appState->getAreaCode();
     $configLoader = $this->objectManager->get('Magento\\Framework\\ObjectManager\\ConfigLoaderInterface');
     $this->objectManager->configure($configLoader->load($area));
     $this->registry->register('isSecureArea', true);
 }
开发者ID:semaio,项目名称:magento2-configimportexport,代码行数:22,代码来源:AbstractCommand.php

示例13: getData

 /**
  * Get translation data
  *
  * @param string $themePath
  * @return array
  * @throws \Exception
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function getData($themePath)
 {
     $areaCode = $this->appState->getAreaCode();
     $files = array_merge($this->filesUtility->getJsFiles('base', $themePath), $this->filesUtility->getJsFiles($areaCode, $themePath), $this->filesUtility->getStaticHtmlFiles('base', $themePath), $this->filesUtility->getStaticHtmlFiles($areaCode, $themePath));
     $dictionary = [];
     foreach ($files as $filePath) {
         /** @var \Magento\Framework\Filesystem\File\Read $read */
         $read = $this->fileReadFactory->create($filePath[0], \Magento\Framework\Filesystem\DriverPool::FILE);
         $content = $read->readAll();
         foreach ($this->getPhrases($content) as $phrase) {
             $translatedPhrase = $this->translate->render([$phrase], []);
             if ($phrase != $translatedPhrase) {
                 $dictionary[$phrase] = $translatedPhrase;
             }
         }
     }
     return $dictionary;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:26,代码来源:DataProvider.php

示例14: getRecurringPaymentType

 /**
  * For admin use RECURRING contract for front-end get it from configuration
  *
  * @return mixed|string
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function getRecurringPaymentType()
 {
     // For admin always use Recurring
     if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
         return \Adyen\Payment\Model\RecurringType::RECURRING;
     } else {
         return $this->adyenHelper->getAdyenOneclickConfigData('recurring_payment_type');
     }
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:15,代码来源:AdyenOneclickDataAssignObserver.php

示例15: setItemStoreId

 /**
  * Set store_id value to quote item
  *
  * @param Item $item
  * @return void
  */
 protected function setItemStoreId(Item $item)
 {
     if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
         $storeId = $this->storeManager->getStore($this->storeManager->getStore()->getId())->getId();
         $item->setStoreId($storeId);
     } else {
         $item->setStoreId($this->storeManager->getStore()->getId());
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:Processor.php


注:本文中的Magento\Framework\App\State::getAreaCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。