当前位置: 首页>>代码示例>>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;未经允许,请勿转载。