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


PHP Observer::getDataByKey方法代码示例

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


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

示例1: execute

 /**
  * Create payment vault record
  *
  * @param Observer $observer
  * @return $this
  */
 public function execute(Observer $observer)
 {
     /** @var OrderPaymentInterface $payment */
     $payment = $observer->getDataByKey(self::PAYMENT_OBJECT_DATA_KEY);
     $extensionAttributes = $payment->getExtensionAttributes();
     $paymentToken = $this->getPaymentToken($extensionAttributes);
     if ($paymentToken === null) {
         return $this;
     }
     if ($paymentToken->getEntityId() !== null) {
         $this->paymentTokenManagement->addLinkToOrderPayment($paymentToken->getEntityId(), $payment->getEntityId());
         return $this;
     }
     $order = $payment->getOrder();
     $paymentToken->setCustomerId($order->getCustomerId());
     $paymentToken->setIsActive(true);
     $paymentToken->setPaymentMethodCode($payment->getMethod());
     $additionalInformation = $payment->getAdditionalInformation();
     if (isset($additionalInformation[VaultConfigProvider::IS_ACTIVE_CODE])) {
         $paymentToken->setIsVisible((bool) (int) $additionalInformation[VaultConfigProvider::IS_ACTIVE_CODE]);
     }
     $paymentToken->setPublicHash($this->generatePublicHash($paymentToken));
     $this->paymentTokenManagement->saveTokenWithPaymentLink($paymentToken, $payment);
     $extensionAttributes->setVaultPaymentToken($paymentToken);
     return $this;
 }
开发者ID:uibar,项目名称:lavinia2,代码行数:32,代码来源:AfterPaymentSaveObserver.php

示例2: execute

 /**
  * Create payment vault record
  *
  * @param Observer $observer
  * @return $this
  */
 public function execute(Observer $observer)
 {
     /** @var OrderPaymentInterface $payment */
     $payment = $observer->getDataByKey(self::PAYMENT_OBJECT_DATA_KEY);
     $extensionAttributes = $payment->getExtensionAttributes();
     $paymentToken = $this->getPaymentToken($extensionAttributes);
     // Save only new tokens that has been set during first order placement
     if ($paymentToken === null || $paymentToken->getEntityId() > 0) {
         return $this;
     }
     $paymentToken->setPublicHash($this->generatePublicHash($paymentToken));
     $paymentToken->setIsActive(true);
     $additionalInformation = $payment->getAdditionalInformation();
     if (isset($additionalInformation[VaultConfigProvider::IS_ACTIVE_CODE])) {
         $paymentToken->setIsVisible((bool) (int) $additionalInformation[VaultConfigProvider::IS_ACTIVE_CODE]);
     }
     $this->paymentTokenManagement->saveTokenWithPaymentLink($paymentToken, $payment);
     $extensionAttributes->setVaultPaymentToken($paymentToken);
     return $this;
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:26,代码来源:AfterPaymentSaveObserver.php


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