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


PHP TransportBuilder::setReplyTo方法代碼示例

本文整理匯總了PHP中Magento\Framework\Mail\Template\TransportBuilder::setReplyTo方法的典型用法代碼示例。如果您正苦於以下問題:PHP TransportBuilder::setReplyTo方法的具體用法?PHP TransportBuilder::setReplyTo怎麽用?PHP TransportBuilder::setReplyTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Mail\Template\TransportBuilder的用法示例。


在下文中一共展示了TransportBuilder::setReplyTo方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sendrequest

 /**
  * @param \Magento\Framework\DataObject $postObject
  *
  * @return bool
  * @throws \Exception
  */
 public function sendrequest($postObject)
 {
     if (!filter_var($postObject->getData('to'), FILTER_VALIDATE_EMAIL)) {
         throw new \Exception($this->_dataHelper->__('Please enter a valid e-mail address.'));
     }
     if (strlen(trim($postObject->getData('replyto')))) {
         if (!filter_var($postObject->getData('replyto'), FILTER_VALIDATE_EMAIL)) {
             throw new \Exception($this->_dataHelper->__('Please enter a valid e-mail address (reply to).'));
         }
         $this->_transportBuilder->setReplyTo(trim($postObject->getData('replyto')));
     }
     $sender = ['name' => $this->_dataHelper->getStoreConfigData('trans_email/ident_general/name'), 'email' => $this->_dataHelper->getStoreConfigData('trans_email/ident_general/email')];
     if (!strlen($sender['email'])) {
         throw new \Exception('Please set your shop e-mail address!');
     }
     $modules = [];
     foreach ($this->_moduleLoader->load() as $module) {
         if (!in_array($module['name'], $this->_moduleBlacklist)) {
             $modules[] = $module['name'];
         }
     }
     natsort($modules);
     $payments = $this->_paymentConfig->getActiveMethods();
     /** @var \Magento\Framework\App\Config\Data $cfg */
     $cfg = $this->_scopePool->getScope(\Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     $foreign = array();
     $mine = array();
     foreach ($payments as $paymentCode => $paymentModel) {
         /** @var AbstractPayment $paymentModel */
         $method = array('label' => $paymentModel->getTitle(), 'value' => $paymentCode, 'config' => []);
         if (preg_match('/^wirecard_/i', $paymentCode)) {
             $method['config'] = $cfg->getValue('payment/' . $paymentCode);
             $mine[$paymentCode] = $method;
         } else {
             $foreign[$paymentCode] = $method;
         }
     }
     $versioninfo = new \Magento\Framework\DataObject();
     $versioninfo->setData($this->_dataHelper->getVersionInfo());
     $transport = $this->_transportBuilder->setTemplateIdentifier('contact_support_email')->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_ADMINHTML, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->setTemplateVars(['data' => $postObject, 'modules' => $modules, 'foreign' => $foreign, 'mine' => $mine, 'configstr' => $this->_dataHelper->getConfigString(), 'versioninfo' => $versioninfo])->setFrom($sender)->addTo($postObject->getData('to'))->getTransport();
     $transport->sendMessage();
     return true;
 }
開發者ID:wirecard,項目名稱:magento2-wcp,代碼行數:49,代碼來源:Support.php

示例2: testSetReplyTo

 /**
  * @covers \Magento\Framework\Mail\Template\TransportBuilder::setReplyTo
  */
 public function testSetReplyTo()
 {
     $this->messageMock->expects($this->once())->method('setReplyTo')->with('replyTo@example.com', 'replyName')->will($this->returnSelf());
     $this->builder->setReplyTo('replyTo@example.com', 'replyName');
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:8,代碼來源:TransportBuilderTest.php


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