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


PHP PageFactory::create方法代码示例

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


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

示例1: execute

 /**
  * Index action
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     $this->initPage($resultPage)->getConfig()->getTitle()->prepend(__('Blocks'));
     return $resultPage;
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:12,代码来源:Index.php

示例2: executeInternal

 /**
  * Edit CMS block
  *
  * @return \Magento\Framework\Controller\ResultInterface
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function executeInternal()
 {
     // 1. Get ID and create model
     $id = $this->getRequest()->getParam('block_id');
     $model = $this->_objectManager->create('Magento\\Cms\\Model\\Block');
     // 2. Initial checking
     if ($id) {
         $model->load($id);
         if (!$model->getId()) {
             $this->messageManager->addError(__('This block no longer exists.'));
             /** @var \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_block', $model);
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     // 5. Build edit form
     $this->initPage($resultPage)->addBreadcrumb($id ? __('Edit Block') : __('New Block'), $id ? __('Edit Block') : __('New Block'));
     $resultPage->getConfig()->getTitle()->prepend(__('Blocks'));
     $resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getTitle() : __('New Block'));
     return $resultPage;
 }
开发者ID:nblair,项目名称:magescotch,代码行数:36,代码来源:Edit.php

示例3: execute

 /**
  * Default customer account page
  *
  * @return \Magento\Framework\View\Result\Page
  */
 public function execute()
 {
     /** @var \Magento\Framework\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     $resultPage->getConfig()->getTitle()->set(__('My Account'));
     return $resultPage;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:Index.php

示例4: execute

 /**
  * @return \Magento\Backend\Model\View\Result\Forward
  */
 public function execute()
 {
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     $resultPage->setActiveMenu('Ves_Setup::export')->addBreadcrumb(__('Ves Setup'), __('Ves Setup'))->addBreadcrumb(__('Export'), __('Export'));
     return $resultPage;
 }
开发者ID:rustamveer,项目名称:magento2,代码行数:10,代码来源:Index.php

示例5: execute

 /**
  * @return void
  */
 public function execute()
 {
     $ipId = $this->getRequest()->getParam('id');
     /** @var \Rapidmage\Firewall\Model\Ip $model */
     $model = $this->_ipFactory->create();
     if ($ipId) {
         $model->load($ipId);
         if (!$model->getId()) {
             $this->messageManager->addError(__('This Ip no longer exists.'));
             $this->_redirect('*/*/');
             return;
         }
     }
     // Restore previously entered form data from session
     $data = $this->_session->getIpData(true);
     if (!empty($data)) {
         $model->setData($data);
     }
     $this->_coreRegistry->register('firewall_blackip', $model);
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->_resultPageFactory->create();
     $resultPage->setActiveMenu('Rapidmage_Firewall::main_menu');
     $resultPage->getConfig()->getTitle()->prepend(__('Firewall'));
     return $resultPage;
 }
开发者ID:DRAJI,项目名称:Rapidmage,代码行数:28,代码来源:Edit.php

示例6: execute

 /**
  * Product edit form
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */
     $storeManager = $this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface');
     $storeId = (int) $this->getRequest()->getParam('store', 0);
     $store = $storeManager->getStore($storeId);
     $storeManager->setCurrentStore($store->getCode());
     $productId = (int) $this->getRequest()->getParam('id');
     $product = $this->productBuilder->build($this->getRequest());
     if ($productId && !$product->getEntityId()) {
         $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:rafaelstz,项目名称:magento2,代码行数:36,代码来源:Edit.php

示例7: execute

 /**
  * Send confirmation link to specified email
  *
  * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page
  */
 public function execute()
 {
     if ($this->session->isLoggedIn()) {
         /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultRedirectFactory->create();
         $resultRedirect->setPath('*/*/');
         return $resultRedirect;
     }
     // try to confirm by email
     $email = $this->getRequest()->getPost('email');
     if ($email) {
         /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultRedirectFactory->create();
         try {
             $this->customerAccountManagement->resendConfirmation($email, $this->storeManager->getStore()->getWebsiteId());
             $this->messageManager->addSuccess(__('Please check your email for confirmation key.'));
         } catch (InvalidTransitionException $e) {
             $this->messageManager->addSuccess(__('This email does not require confirmation.'));
         } catch (\Exception $e) {
             $this->messageManager->addException($e, __('Wrong email.'));
             $resultRedirect->setPath('*/*/*', ['email' => $email, '_secure' => true]);
             return $resultRedirect;
         }
         $this->session->setUsername($email);
         $resultRedirect->setPath('*/*/index', ['_secure' => true]);
         return $resultRedirect;
     }
     /** @var \Magento\Framework\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     $resultPage->getLayout()->getBlock('accountConfirmation')->setEmail($this->getRequest()->getParam('email', $email));
     return $resultPage;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:37,代码来源:Confirmation.php

示例8: createPage

 /**
  * Initialize Layout and set breadcrumbs
  *
  * @return \Magento\Backend\Model\View\Result\Page
  */
 protected function createPage()
 {
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     $resultPage->setActiveMenu('SweetTooth_Webhook::system_webhook')->addBreadcrumb(__('Webhooks'), __('Webhooks'));
     return $resultPage;
 }
开发者ID:defyasdf,项目名称:magento2-module-webhook,代码行数:12,代码来源:Webhook.php

示例9: executeInternal

 /**
  * @return \Magento\Framework\View\Result\LayoutFactory
  */
 public function executeInternal()
 {
     $resultLayout = $this->resultPageFactory->create();
     $resultLayout->setStatusHeader(404, '1.1', 'Not Found');
     $resultLayout->setHeader('Status', '404 File not found');
     return $resultLayout;
 }
开发者ID:nblair,项目名称:magescotch,代码行数:10,代码来源:DefaultNoRoute.php

示例10: execute

 /**
  * Action to reconfigure cart item
  *
  * @return \Magento\Framework\View\Result\Page|\Magento\Framework\Controller\Result\Redirect
  */
 public function execute()
 {
     // Extract item and product to configure
     $id = (int) $this->getRequest()->getParam('id');
     $productId = (int) $this->getRequest()->getParam('product_id');
     $quoteItem = null;
     if ($id) {
         $quoteItem = $this->cart->getQuote()->getItemById($id);
     }
     try {
         if (!$quoteItem || $productId != $quoteItem->getProduct()->getId()) {
             $this->messageManager->addError(__("We can't find the quote item."));
             return $this->resultRedirectFactory->create()->setPath('checkout/cart');
         }
         $params = new \Magento\Framework\Object();
         $params->setCategoryId(false);
         $params->setConfigureMode(true);
         $params->setBuyRequest($quoteItem->getBuyRequest());
         $resultPage = $this->resultPageFactory->create();
         $this->_objectManager->get('Magento\\Catalog\\Helper\\Product\\View')->prepareAndRender($resultPage, $quoteItem->getProduct()->getId(), $this, $params);
         return $resultPage;
     } catch (\Exception $e) {
         $this->messageManager->addError(__('We cannot configure the product.'));
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
         return $this->_goBack();
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:32,代码来源:Configure.php

示例11: execute

 /**
  * Dispatch request
  *
  * @return \Magento\Framework\Controller\ResultInterface|ResponseInterface
  * @throws \Magento\Framework\Exception\NotFoundException
  */
 public function execute()
 {
     // 1. Get ID and create model
     $id = $this->getRequest()->getParam('id');
     $model = $this->_objectManager->create('Fastgento\\Storelocator\\Model\\Location');
     // 2. Initial checking
     if ($id) {
         $model->load($id);
         if (!$model->getId()) {
             $this->messageManager->addError(__('This block no longer exists.'));
             /** @var \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);
     // 4. Register model to use later in blocks
     $this->_coreRegistry->register('location', $model);
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     if (is_array($data)) {
         if (isset($data['image']['delete'])) {
             $data['image'] = null;
         } else {
             unset($data['image']);
         }
         $model->addData($data);
     }
     // 5. Build edit form
     $this->initPage($resultPage)->addBreadcrumb($id ? __('Edit Location') : __('New Location'), $id ? __('Edit Location') : __('New Location'));
     //$resultPage->getConfig()->getTitle()->prepend(__('Locations'));
     //$resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getName() : __('New Location'));
     return $resultPage;
 }
开发者ID:ant-workaholic,项目名称:Store-locator,代码行数:41,代码来源:Edit.php

示例12: execute

 /**
  * Promo quote edit action
  *
  * @return void
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function execute()
 {
     $id = $this->getRequest()->getParam('id');
     $model = $this->_objectManager->create('Magento\\SalesRule\\Model\\Rule');
     $this->_coreRegistry->register(\Magento\SalesRule\Model\RegistryConstants::CURRENT_SALES_RULE, $model);
     $resultPage = $this->resultPageFactory->create();
     if ($id) {
         $model->load($id);
         if (!$model->getRuleId()) {
             $this->messageManager->addError(__('This rule no longer exists.'));
             $this->_redirect('sales_rule/*');
             return;
         }
         $resultPage->getLayout()->getBlock('promo_sales_rule_edit_tab_coupons')->setCanShow(true);
     }
     // set entered data if was error when we do save
     $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getPageData(true);
     if (!empty($data)) {
         $model->addData($data);
     }
     $model->getConditions()->setFormName('sales_rule_form');
     $model->getConditions()->setJsFormObject($model->getConditionsFieldSetId($model->getConditions()->getFormName()));
     $model->getActions()->setFormName('sales_rule_form');
     $model->getActions()->setJsFormObject($model->getActionsFieldSetId($model->getActions()->getFormName()));
     $this->_initAction();
     $this->_addBreadcrumb($id ? __('Edit Rule') : __('New Rule'), $id ? __('Edit Rule') : __('New Rule'));
     $this->_view->getPage()->getConfig()->getTitle()->prepend($model->getRuleId() ? $model->getName() : __('New Cart Price Rule'));
     $this->_view->renderLayout();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:35,代码来源:Edit.php

示例13: _initAction

 /**
  * Init layout, menu and breadcrumb
  *
  * @return \Magento\Backend\Model\View\Result\Page
  */
 protected function _initAction()
 {
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     $resultPage->setActiveMenu('Magento_Sales::sales_invoice')->addBreadcrumb(__('Sales'), __('Sales'))->addBreadcrumb(__('Invoices'), __('Invoices'));
     return $resultPage;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:12,代码来源:Index.php

示例14: execute

 /**
  * Shopping cart display action
  *
  * @return \Magento\Framework\View\Result\Page
  */
 public function execute()
 {
     $resultPage = $this->resultPageFactory->create();
     $resultPage->getLayout()->initMessages();
     $resultPage->getConfig()->getTitle()->set(__('Shopping Cart'));
     return $resultPage;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:12,代码来源:Index.php

示例15: execute

 /**
  * Create new product page
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     if (!$this->getRequest()->getParam('set')) {
         return $this->resultForwardFactory->create()->forward('noroute');
     }
     $product = $this->productBuilder->build($this->getRequest());
     $productData = $this->getRequest()->getPost('product');
     if (!$productData) {
         $sessionData = $this->_session->getProductData(true);
         if (!empty($sessionData['product'])) {
             $productData = $sessionData['product'];
         }
     }
     if ($productData) {
         $stockData = isset($productData['stock_data']) ? $productData['stock_data'] : [];
         $productData['stock_data'] = $this->stockFilter->filter($stockData);
         $product = $this->getInitializationHelper()->initializeFromData($product, $productData);
     }
     $this->_eventManager->dispatch('catalog_product_new_action', ['product' => $product]);
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     if ($this->getRequest()->getParam('popup')) {
         $resultPage->addHandle(['popup', 'catalog_product_' . $product->getTypeId()]);
     } else {
         $resultPage->addHandle(['catalog_product_' . $product->getTypeId()]);
         $resultPage->setActiveMenu('Magento_Catalog::catalog_products');
         $resultPage->getConfig()->getTitle()->prepend(__('Products'));
         $resultPage->getConfig()->getTitle()->prepend(__('New Product'));
     }
     $block = $resultPage->getLayout()->getBlock('catalog.wysiwyg.js');
     if ($block) {
         $block->setStoreId($product->getStoreId());
     }
     return $resultPage;
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:40,代码来源:NewAction.php


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