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


PHP RedirectFactory::create方法代码示例

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


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

示例1: _redirectToOrder

 /**
  * Redirect to order view page
  *
  * @param int $orderId
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 protected function _redirectToOrder($orderId)
 {
     /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath('sales/order/view', ['order_id' => $orderId]);
     return $resultRedirect;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:NewAction.php

示例2: execute

 /**
  * Edit CMS page
  *
  * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function execute()
 {
     // 1. Get ID and create model
     $id = $this->getRequest()->getParam('page_id');
     $model = $this->_objectManager->create('Magento\\Cms\\Model\\Page');
     // 2. Initial checking
     if ($id) {
         $model->load($id);
         if (!$model->getId()) {
             $this->messageManager->addError(__('This page no longer exists.'));
             /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
             $resultRedirect = $this->resultRedirectFactory->create();
             return $resultRedirect->setPath('*/*/');
         }
     }
     // 3. Set entered data if was error when we do save
     $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getFormData(true);
     if (!empty($data)) {
         $model->setData($data);
     }
     // 4. Register model to use later in blocks
     $this->_coreRegistry->register('cms_page', $model);
     // 5. Build edit form
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->_initAction();
     $resultPage->addBreadcrumb($id ? __('Edit Page') : __('New Page'), $id ? __('Edit Page') : __('New Page'));
     $resultPage->getConfig()->getTitle()->prepend(__('Pages'));
     $resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getTitle() : __('New Page'));
     return $resultPage;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:36,代码来源:Edit.php

示例3: execute

 /**
  * Save status assignment to state
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     $data = $this->getRequest()->getPostValue();
     /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultRedirectFactory->create();
     if ($data) {
         $state = $this->getRequest()->getParam('state');
         $isDefault = $this->getRequest()->getParam('is_default');
         $visibleOnFront = $this->getRequest()->getParam('visible_on_front');
         $status = $this->_initStatus();
         if ($status && $status->getStatus()) {
             try {
                 $status->assignState($state, $isDefault, $visibleOnFront);
                 $this->messageManager->addSuccess(__('You have assigned the order status.'));
                 return $resultRedirect->setPath('sales/*/');
             } catch (\Magento\Framework\Exception\LocalizedException $e) {
                 $this->messageManager->addError($e->getMessage());
             } catch (\Exception $e) {
                 $this->messageManager->addException($e, __('An error occurred while assigning order status. Status has not been assigned.'));
             }
         } else {
             $this->messageManager->addError(__('We can\'t find this order status.'));
         }
         return $resultRedirect->setPath('sales/*/assign');
     }
     return $resultRedirect->setPath('sales/*/');
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:32,代码来源:AssignPost.php

示例4: execute

 /**
  * Product edit form
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $productId = (int) $this->getRequest()->getParam('id');
     $product = $this->productBuilder->build($this->getRequest());
     if ($productId && !$product->getId()) {
         $this->messageManager->addError(__('This product no longer exists.'));
         /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultRedirectFactory->create();
         return $resultRedirect->setPath('catalog/*/');
     }
     $this->_eventManager->dispatch('catalog_product_edit_action', ['product' => $product]);
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     $resultPage->addHandle('catalog_product_' . $product->getTypeId());
     $resultPage->setActiveMenu('Magento_Catalog::catalog_products');
     $resultPage->getConfig()->getTitle()->prepend(__('Products'));
     $resultPage->getConfig()->getTitle()->prepend($product->getName());
     if (!$this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->isSingleStoreMode() && ($switchBlock = $resultPage->getLayout()->getBlock('store_switcher'))) {
         $switchBlock->setDefaultStoreName(__('Default Values'))->setWebsiteIds($product->getWebsiteIds())->setSwitchUrl($this->getUrl('catalog/*/*', ['_current' => true, 'active_tab' => null, 'tab' => null, 'store' => null]));
     }
     $block = $resultPage->getLayout()->getBlock('catalog.wysiwyg.js');
     if ($block) {
         $block->setStoreId($product->getStoreId());
     }
     return $resultPage;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:31,代码来源:Edit.php

示例5: execute

 /**
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     if (!$this->_validateProducts()) {
         return $this->resultRedirectFactory->create()->setPath('catalog/product/', ['_current' => true]);
     }
     return $this->resultPageFactory->create();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:Edit.php

示例6: execute

 /**
  * Save product action
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute()
 {
     $storeId = $this->getRequest()->getParam('store');
     $redirectBack = $this->getRequest()->getParam('back', false);
     $productId = $this->getRequest()->getParam('id');
     $resultRedirect = $this->resultRedirectFactory->create();
     $data = $this->getRequest()->getPostValue();
     if ($data) {
         try {
             $product = $this->initializationHelper->initialize($this->productBuilder->build($this->getRequest()));
             $this->productTypeManager->processProduct($product);
             if (isset($data['product'][$product->getIdFieldName()])) {
                 throw new \Magento\Framework\Exception\LocalizedException(__('Unable to save product'));
             }
             $originalSku = $product->getSku();
             $product->save();
             $productId = $product->getId();
             /**
              * Do copying data to stores
              */
             if (isset($data['copy_to_stores'])) {
                 foreach ($data['copy_to_stores'] as $storeTo => $storeFrom) {
                     $this->_objectManager->create('Magento\\Catalog\\Model\\Product')->setStoreId($storeFrom)->load($productId)->setStoreId($storeTo)->save();
                 }
             }
             $this->messageManager->addSuccess(__('You saved the product.'));
             if ($product->getSku() != $originalSku) {
                 $this->messageManager->addNotice(__('SKU for product %1 has been changed to %2.', $this->_objectManager->get('Magento\\Framework\\Escaper')->escapeHtml($product->getName()), $this->_objectManager->get('Magento\\Framework\\Escaper')->escapeHtml($product->getSku())));
             }
             $this->_eventManager->dispatch('controller_action_catalog_product_save_entity_after', ['controller' => $this]);
             if ($redirectBack === 'duplicate') {
                 $newProduct = $this->productCopier->copy($product);
                 $this->messageManager->addSuccess(__('You duplicated the product.'));
             }
         } catch (\Magento\Framework\Exception\LocalizedException $e) {
             $this->messageManager->addError($e->getMessage());
             $this->_session->setProductData($data);
             $redirectBack = $productId ? true : 'new';
         } catch (\Exception $e) {
             $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
             $this->messageManager->addError($e->getMessage());
             $this->_session->setProductData($data);
             $redirectBack = $productId ? true : 'new';
         }
     } else {
         $resultRedirect->setPath('catalog/*/', ['store' => $storeId]);
         $this->messageManager->addError('No data to save');
         return $resultRedirect;
     }
     if ($redirectBack === 'new') {
         $resultRedirect->setPath('catalog/*/new', ['set' => $product->getAttributeSetId(), 'type' => $product->getTypeId()]);
     } elseif ($redirectBack === 'duplicate' && isset($newProduct)) {
         $resultRedirect->setPath('catalog/*/edit', ['id' => $newProduct->getId(), 'back' => null, '_current' => true]);
     } elseif ($redirectBack) {
         $resultRedirect->setPath('catalog/*/edit', ['id' => $productId, '_current' => true]);
     } else {
         $resultRedirect->setPath('catalog/*/', ['store' => $storeId]);
     }
     return $resultRedirect;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:66,代码来源:Save.php

示例7: execute

 /**
  * Delete action
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultRedirectFactory->create();
     // check if we know what should be deleted
     $id = $this->getRequest()->getParam('block_id');
     if ($id) {
         try {
             // init model and delete
             $model = $this->_objectManager->create('Magento\\Cms\\Model\\Block');
             $model->load($id);
             $model->delete();
             // display success message
             $this->messageManager->addSuccess(__('The block has been deleted.'));
             // go to grid
             return $resultRedirect->setPath('*/*/');
         } catch (\Exception $e) {
             // display error message
             $this->messageManager->addError($e->getMessage());
             // go back to edit form
             return $resultRedirect->setPath('*/*/edit', ['block_id' => $id]);
         }
     }
     // display error message
     $this->messageManager->addError(__('We can\'t find a block to delete.'));
     // go to grid
     return $resultRedirect->setPath('*/*/');
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:33,代码来源:Delete.php

示例8: execute

 /**
  * Void creditmemo action
  *
  * @return \Magento\Backend\Model\View\Result\Redirect|\Magento\Backend\Model\View\Result\Forward
  */
 public function execute()
 {
     $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id'));
     $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id'));
     $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo'));
     $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id'));
     $creditmemo = $this->creditmemoLoader->load();
     if ($creditmemo) {
         try {
             $creditmemo->void();
             $transactionSave = $this->_objectManager->create('Magento\\Framework\\DB\\Transaction');
             $transactionSave->addObject($creditmemo);
             $transactionSave->addObject($creditmemo->getOrder());
             if ($creditmemo->getInvoice()) {
                 $transactionSave->addObject($creditmemo->getInvoice());
             }
             $transactionSave->save();
             $this->messageManager->addSuccess(__('You voided the credit memo.'));
         } catch (\Magento\Framework\Exception\LocalizedException $e) {
             $this->messageManager->addError($e->getMessage());
         } catch (\Exception $e) {
             $this->messageManager->addError(__('We can\'t void the credit memo.'));
         }
         $resultRedirect = $this->resultRedirectFactory->create();
         $resultRedirect->setPath('sales/*/view', ['creditmemo_id' => $creditmemo->getId()]);
         return $resultRedirect;
     } else {
         $resultForward = $this->resultForwardFactory->create();
         $resultForward->forward('noroute');
         return $resultForward;
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:37,代码来源:Void.php

示例9: execute

 /**
  * Administrator logout action
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     $this->_auth->logout();
     $this->messageManager->addSuccess(__('You have logged out.'));
     /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultRedirectFactory->create();
     return $resultRedirect->setPath($this->_helper->getHomePageUrl());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:Logout.php

示例10: execute

 /**
  * Start create creditmemo action
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     /**
      * Clear old values for creditmemo qty's
      */
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath('sales/*/new', ['_current' => true]);
     return $resultRedirect;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:Start.php

示例11: execute

 /**
  * Administrator login action
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     if ($this->_auth->isLoggedIn()) {
         if ($this->_auth->getAuthStorage()->isFirstPageAfterLogin()) {
             $this->_auth->getAuthStorage()->setIsFirstPageAfterLogin(true);
         }
         /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultRedirectFactory->create();
         $resultRedirect->setPath($this->_backendUrl->getStartupPageUrl());
         return $resultRedirect;
     }
     return $this->resultPageFactory->create();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:Login.php

示例12: execute

 /**
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     if (!$this->_auth->isLoggedIn()) {
         /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultRedirectFactory->create();
         $resultRedirect->setStatusHeader(403, '1.1', 'Forbidden');
         return $resultRedirect->setPath('*/auth/login');
     }
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     $resultPage->setStatusHeader(403, '1.1', 'Forbidden');
     $resultPage->addHandle('adminhtml_denied');
     return $resultPage;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:Denied.php

示例13: execute

 /**
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     $setId = $this->getRequest()->getParam('id');
     $resultRedirect = $this->resultRedirectFactory->create();
     try {
         $this->attributeSetRepository->deleteById($setId);
         $this->messageManager->addSuccess(__('The attribute set has been removed.'));
         $resultRedirect->setPath('catalog/*/');
     } catch (\Exception $e) {
         $this->messageManager->addError(__('An error occurred while deleting this set.'));
         $resultRedirect->setUrl($this->_redirect->getRedirectUrl($this->getUrl('*')));
     }
     return $resultRedirect;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:Delete.php

示例14: execute

 /**
  * Notify user
  *
  * @return \Magento\Backend\Model\View\Result\Forward|\Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     $invoiceId = $this->getRequest()->getParam('invoice_id');
     if (!$invoiceId) {
         return $this->resultForwardFactory->create()->forward('noroute');
     }
     $invoice = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Invoice')->load($invoiceId);
     if (!$invoice) {
         return $this->resultForwardFactory->create()->forward('noroute');
     }
     $this->_objectManager->create('Magento\\Sales\\Model\\Order\\InvoiceNotifier')->notify($invoice);
     $this->messageManager->addSuccess(__('We sent the message.'));
     return $this->resultRedirectFactory->create()->setPath('sales/invoice/view', ['order_id' => $invoice->getOrder()->getId(), 'invoice_id' => $invoiceId]);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:19,代码来源:Email.php

示例15: execute

 /**
  * Create product duplicate
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultRedirectFactory->create();
     $product = $this->productBuilder->build($this->getRequest());
     try {
         $newProduct = $this->productCopier->copy($product);
         $this->messageManager->addSuccess(__('You duplicated the product.'));
         $resultRedirect->setPath('catalog/*/edit', ['_current' => true, 'id' => $newProduct->getId()]);
     } catch (\Exception $e) {
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
         $this->messageManager->addError($e->getMessage());
         $resultRedirect->setPath('catalog/*/edit', ['_current' => true]);
     }
     return $resultRedirect;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:21,代码来源:Duplicate.php


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