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


PHP ResultFactory::create方法代碼示例

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


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

示例1: execute

 /**
  * @return \Magento\Backend\Model\View\Result\Page
  */
 public function execute()
 {
     if ($this->initModel()) {
         /* @var \Magento\Backend\Model\View\Result\Page $resultPage */
         $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
         return $resultPage;
     } else {
         $this->_forward('no_route');
     }
 }
開發者ID:mirasvit,項目名稱:module-blog,代碼行數:13,代碼來源:View.php

示例2: getRedirect

 /**
  * Retrieve redirect
  *
  * @return ResultRedirect|ResultForward
  */
 public function getRedirect()
 {
     $this->updateLastCustomerId();
     $this->prepareRedirectUrl();
     /** @var ResultRedirect|ResultForward $result */
     if ($this->session->getBeforeRequestParams()) {
         $result = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
         $result->setParams($this->session->getBeforeRequestParams())->setModule($this->session->getBeforeModuleName())->setController($this->session->getBeforeControllerName())->forward($this->session->getBeforeAction());
     } else {
         $result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
         $result->setUrl($this->session->getBeforeAuthUrl(true));
     }
     return $result;
 }
開發者ID:Zash22,項目名稱:magento,代碼行數:19,代碼來源:Redirect.php

示例3: aroundExecute

 /**
  * @return \Magento\Framework\Controller\Result\Json|\Magento\Framework\Controller\Result\Redirect|null
  */
 public function aroundExecute()
 {
     $query = $this->request->getParam('q', false);
     if (!$query) {
         /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
         $resultRedirect->setUrl($this->url->getBaseUrl());
         return $resultRedirect;
     }
     if ($this->bxHelperData->isAutocompleteEnabled()) {
         $responseData = $this->p13nHelper->autocomplete($query, $this->autocompleteHelper);
         /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
         $resultJson->setData($responseData);
         return $resultJson;
     }
     return null;
 }
開發者ID:boxalino,項目名稱:plugin-magento2,代碼行數:21,代碼來源:AjaxPlugin.php

示例4: execute

 public function execute()
 {
     $email = $this->getRequest()->getParam('email', false);
     $list = $this->getRequest()->getParam('list', false);
     $store = $this->getRequest()->getParam('store', false);
     if ($email && $list && $store) {
         $collection = $this->_objectManager->create('\\Ebizmarts\\Mandrill\\Model\\Unsubscribe')->getCollection();
         $collection->addFieldToFilter('main_table.email', array('eq' => $email))->addFieldToFilter('main_table.list', array('eq' => $list))->addFieldToFilter('main_table.store_id', array('eq' => $store))->limit(1);
         if ($collection->getSize() == 0) {
             $unsubscribe = $this->_objectManager->create('\\Ebizmarts\\Mandrill\\Model\\Unsubscribe');
             $unsubscribe->setEmail($email)->setList($list)->setStoreId($store)->setUnsubscribedAt(date('Y-m-d H:i:s'));
             $unsubscribe->save();
             $this->messageManager->addNotice("You are unsubcribed from {$list}");
         } else {
             $this->messageManager->addNotice("You are already unsubcribed from {$list}");
         }
     } else {
         $this->messageManager->addNotice("Invalid url format");
     }
     $resultRedirect = $this->_resultRedirectFactory->create();
     $resultRedirect->setPath('/');
     return $resultRedirect;
 }
開發者ID:ebizmarts,項目名稱:magento2-mandrill,代碼行數:23,代碼來源:Unsubscribe.php


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