本文整理汇总了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');
}
}
示例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;
}
示例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;
}
示例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;
}