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


PHP State::emulateAreaCode方法代码示例

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


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

示例1: 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

示例2: _beforeToHtml

 /**
  * Add necessary options
  *
  * @return \Magento\Framework\View\Element\AbstractBlock
  */
 protected function _beforeToHtml()
 {
     if (!$this->getOptions()) {
         $this->addOption('', __('-- Please Select --'));
         $layoutUpdateParams = array('theme' => $this->_getThemeInstance($this->getTheme()));
         $designAbstractions = $this->_appState->emulateAreaCode('frontend', array($this->_getLayoutProcessor($layoutUpdateParams), 'getAllDesignAbstractions'));
         $this->_addDesignAbstractionOptions($designAbstractions);
     }
     return parent::_beforeToHtml();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:DesignAbstraction.php

示例3: exec

 /**
  * Execute SampleData module installation.
  * Catch exception if it appeared and continue installation
  *
  * @param InstallerInterface $installer
  * @return void
  */
 public function exec(InstallerInterface $installer)
 {
     try {
         $this->appState->emulateAreaCode('setup', [$installer, 'install']);
         $this->state->setInstalled();
     } catch (\Exception $e) {
         $this->state->setError();
         $this->logger->error('Sample Data error: ' . $e->getMessage());
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:Executor.php

示例4: execute

 /**
  * Main method ran during event raise
  *
  * @param \Magento\Framework\Event\Observer $observer
  */
 public function execute(Observer $observer)
 {
     if (!$this->canRun()) {
         return false;
     }
     $order = $observer->getOrder();
     if (!$order || !$order->getId()) {
         return false;
     }
     $this->logger->addInfo("Auto-invoicing  order " . $order->getId());
     if (!$order->canInvoice() || $order->getState() != \Magento\Sales\Model\Order::STATE_PROCESSING) {
         $this->logger->addInfo("Order cannot be invoiced");
         if ($this->apiConfig->isLoggingEnabled()) {
             $this->apiOrderLogger->logInvoice($order);
         }
         return false;
     }
     $invoice = $this->state->emulateAreaCode('adminhtml', array($this->invoiceService, 'prepareInvoice'), array($order));
     if (!$invoice->getTotalQty()) {
         $this->logger->addInfo("Cannot create an invoice without products");
         return;
     }
     try {
         $invoice->setRequestedCaptureCase($this->apiConfig->getCaptureCase())->addComment(__('Invoice automatically created by Riskified when order was approved'), false, false)->register();
         $order->setStatus('riskified_approved');
         $order->addStatusHistoryComment(__("Reviewed and approved by Riskified"), 'riskified_approved');
         $order->save();
     } catch (\Exception $e) {
         $this->logger->addInfo("Error creating invoice: " . $e->getMessage());
         return false;
     }
     try {
         $invoice->save();
         $invoice->getOrder()->save();
     } catch (\Exception $e) {
         $this->logger->addCritical("Error creating transaction: " . $e->getMessage());
         return false;
     }
     $this->logger->addInfo("Transaction saved");
 }
开发者ID:Riskified,项目名称:magento2,代码行数:45,代码来源:AutoInvoice.php

示例5: layoutDirective

 /**
  * Retrieve layout html directive
  *
  * @param string[] $construction
  * @return string
  */
 public function layoutDirective($construction)
 {
     $this->_directiveParams = $this->_getParameters($construction[2]);
     if (!isset($this->_directiveParams['area'])) {
         $this->_directiveParams['area'] = 'frontend';
     }
     if ($this->_directiveParams['area'] != $this->_appState->getAreaCode()) {
         return $this->_appState->emulateAreaCode($this->_directiveParams['area'], [$this, 'emulateAreaCallback']);
     } else {
         return $this->emulateAreaCallback();
     }
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:18,代码来源:Filter.php

示例6: layoutDirective

 /**
  * Retrieve layout html directive
  *
  * @param string[] $construction
  * @return string
  */
 public function layoutDirective($construction)
 {
     $this->_directiveParams = $this->getParameters($construction[2]);
     if (!isset($this->_directiveParams['area'])) {
         $this->_directiveParams['area'] = \Magento\Framework\App\Area::AREA_FRONTEND;
     }
     if ($this->_directiveParams['area'] != $this->_appState->getAreaCode()) {
         return $this->_appState->emulateAreaCode($this->_directiveParams['area'], [$this, 'emulateAreaCallback']);
     } else {
         return $this->emulateAreaCallback();
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:Filter.php


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