• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Framework\Registry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Framework\Registry的典型用法代码示例。如果您正苦于以下问题:PHP Registry类的具体用法?PHP Registry怎么用?PHP Registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: execute

 /**
  * Print Invoice Action
  *
  * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page
  */
 public function execute()
 {
     $invoiceId = (int) $this->getRequest()->getParam('invoice_id');
     if ($invoiceId) {
         $invoice = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Invoice')->load($invoiceId);
         $order = $invoice->getOrder();
     } else {
         $orderId = (int) $this->getRequest()->getParam('order_id');
         $order = $this->_objectManager->create('Magento\\Sales\\Model\\Order')->load($orderId);
     }
     if ($this->orderAuthorization->canView($order)) {
         $this->_coreRegistry->register('current_order', $order);
         if (isset($invoice)) {
             $this->_coreRegistry->register('current_invoice', $invoice);
         }
         /** @var \Magento\Framework\View\Result\Page $resultPage */
         $resultPage = $this->resultPageFactory->create();
         $resultPage->addHandle('print');
         return $resultPage;
     } else {
         /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultRedirectFactory->create();
         if ($this->_objectManager->get('Magento\\Customer\\Model\\Session')->isLoggedIn()) {
             $resultRedirect->setPath('*/*/history');
         } else {
             $resultRedirect->setPath('sales/guest/form');
         }
         return $resultRedirect;
     }
 }
开发者ID:opexsw,项目名称:magento2,代码行数:35,代码来源:PrintInvoice.php


示例2: execute

 /**
  * @return \Magento\Framework\Controller\ResultInterface
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function execute()
 {
     $id = $this->getRequest()->getParam('id');
     $model = $this->_objectManager->create('Magento\\Search\\Model\\Query');
     if ($id) {
         $model->load($id);
         if (!$model->getId()) {
             $this->messageManager->addError(__('This search no longer exists.'));
             /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
             $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
             $resultRedirect->setPath('search/*');
             return $resultRedirect;
         }
     }
     // 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);
     }
     $this->coreRegistry->register('current_catalog_search', $model);
     $resultPage = $this->createPage();
     $resultPage->getConfig()->getTitle()->prepend(__('Search Terms'));
     $resultPage->getConfig()->getTitle()->prepend($id ? $model->getQueryText() : __('New Search'));
     $resultPage->getLayout()->getBlock('adminhtml.search.term.edit')->setData('action', $this->getUrl('search/term/save'));
     $resultPage->addBreadcrumb($id ? __('Edit Search') : __('New Search'), $id ? __('Edit Search') : __('New Search'));
     return $resultPage;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:31,代码来源:Edit.php


示例3: execute

 /**
  * Print Invoice Action
  *
  * @return void
  */
 public function execute()
 {
     $invoiceId = (int) $this->getRequest()->getParam('invoice_id');
     if ($invoiceId) {
         $invoice = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Invoice')->load($invoiceId);
         $order = $invoice->getOrder();
     } else {
         $orderId = (int) $this->getRequest()->getParam('order_id');
         $order = $this->_objectManager->create('Magento\\Sales\\Model\\Order')->load($orderId);
     }
     if ($this->orderAuthorization->canView($order)) {
         $this->_coreRegistry->register('current_order', $order);
         if (isset($invoice)) {
             $this->_coreRegistry->register('current_invoice', $invoice);
         }
         $this->_view->loadLayout('print');
         $this->_view->renderLayout();
     } else {
         if ($this->_objectManager->get('Magento\\Customer\\Model\\Session')->isLoggedIn()) {
             $this->_redirect('*/*/history');
         } else {
             $this->_redirect('sales/guest/form');
         }
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:30,代码来源:PrintInvoice.php


示例4: getLog

 /**
  * Get log model
  *
  * @return \ClassyLlama\AvaTax\Model\Log
  */
 public function getLog()
 {
     if (null === $this->currentLog) {
         $this->currentLog = $this->coreRegistry->registry('current_log');
     }
     return $this->currentLog;
 }
开发者ID:classyllama,项目名称:ClassyLlama_AvaTax,代码行数:12,代码来源:View.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

 public function execute()
 {
     // 1. Get ID and create model
     $id = $this->getRequest()->getParam("cat_id");
     $model = $this->_objectManager->create("OsmanSorkar\\Blog\\Model\\Category");
     if ($id) {
         $model->load($id);
         if (!$model->getId()) {
             $this->messageManager->addError(__("This Category no longer exists"));
             /** \Magento\Backend\Model\View\Result\Redirct $resultRedirct */
             $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('blog_category', $model);
     // 5. Build edit form
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->resultPageFactory->create();
     $resultPage->setActiveMenu('Ashsmith_Blog::category');
     $resultPage->addBreadcrumb(__('Blog Category Edit'), __('Blog Category Edit'));
     $resultPage->addBreadcrumb(__('Manage Blog Category'), __('Manage Blog Category'));
     $resultPage->getConfig()->getTitle()->prepend(__('Blog Category Edit'));
     return $resultPage;
 }
开发者ID:osmansorkar,项目名称:magento2-blog-module,代码行数:30,代码来源:Edit.php


示例7: executeInternal

    /**
     * Action for reorder
     *
     * @return \Magento\Framework\Controller\ResultInterface
     */
    public function executeInternal()
    {
        $result = $this->orderLoader->load($this->_request);
        if ($result instanceof \Magento\Framework\Controller\ResultInterface) {
            return $result;
        }
        $order = $this->_coreRegistry->registry('current_order');
        /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
        $resultRedirect = $this->resultRedirectFactory->create();

        /* @var $cart \Magento\Checkout\Model\Cart */
        $cart = $this->_objectManager->get('Magento\Checkout\Model\Cart');
        $items = $order->getItemsCollection();
        foreach ($items as $item) {
            try {
                $cart->addOrderItem($item);
            } catch (\Magento\Framework\Exception\LocalizedException $e) {
                if ($this->_objectManager->get('Magento\Checkout\Model\Session')->getUseNotice(true)) {
                    $this->messageManager->addNotice($e->getMessage());
                } else {
                    $this->messageManager->addError($e->getMessage());
                }
                return $resultRedirect->setPath('*/*/history');
            } catch (\Exception $e) {
                $this->messageManager->addException($e, __('We can\'t add this item to your shopping cart right now.'));
                return $resultRedirect->setPath('checkout/cart');
            }
        }

        $cart->save();
        return $resultRedirect->setPath('checkout/cart');
    }
开发者ID:nblair,项目名称:magescotch,代码行数:37,代码来源:Reorder.php


示例8: execute

 /**
  * @return \Magento\Framework\Controller\Result\Forward|\Magento\Framework\View\Result\Page
  */
 public function execute()
 {
     $articleId = (int) $this->getRequest()->getParam('id');
     $article = $this->articleFactory->create();
     $article->load($articleId);
     if (!$article->isActive()) {
         $resultForward = $this->resultForwardFactory->create();
         $resultForward->forward('noroute');
         return $resultForward;
     }
     $this->coreRegistry->register('current_article', $article);
     $resultPage = $this->resultPageFactory->create();
     $title = $article->getMetaTitle() ?: $article->getName();
     $resultPage->getConfig()->getTitle()->set($title);
     $resultPage->getConfig()->setDescription($article->getMetaDescription());
     $resultPage->getConfig()->setKeywords($article->getMetaKeywords());
     if ($this->scopeConfig->isSetFlag(self::BREADCRUMBS_CONFIG_PATH, ScopeInterface::SCOPE_STORE)) {
         /** @var \Magento\Theme\Block\Html\Breadcrumbs $breadcrumbsBlock */
         $breadcrumbsBlock = $resultPage->getLayout()->getBlock('breadcrumbs');
         if ($breadcrumbsBlock) {
             $breadcrumbsBlock->addCrumb('home', ['label' => __('Home'), 'link' => $this->_url->getUrl('')]);
             $breadcrumbsBlock->addCrumb('articles', ['label' => __('Articles'), 'link' => $this->urlModel->getListUrl()]);
             $breadcrumbsBlock->addCrumb('article-' . $article->getId(), ['label' => $article->getName()]);
         }
     }
     return $resultPage;
 }
开发者ID:pleminh,项目名称:Gemtoo,代码行数:30,代码来源:View.php


示例9: _beforeToHtml

 /**
  * Execute before toHtml() code.
  *
  * @return $this
  */
 public function _beforeToHtml()
 {
     $this->_currency = $this->_currencyFactory->create()->load($this->_scopeConfig->getValue(Currency::XML_PATH_CURRENCY_BASE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE));
     $this->_collection = $this->_collectionFactory->create()->setCustomerIdFilter((int) $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID))->setOrderStateFilter(Order::STATE_CANCELED, true)->load();
     $this->_groupedCollection = [];
     foreach ($this->_collection as $sale) {
         if ($sale->getStoreId() !== null) {
             $store = $this->_storeManager->getStore($sale->getStoreId());
             $websiteId = $store->getWebsiteId();
             $groupId = $store->getGroupId();
             $storeId = $store->getId();
             $sale->setWebsiteId($store->getWebsiteId());
             $sale->setWebsiteName($store->getWebsite()->getName());
             $sale->setGroupId($store->getGroupId());
             $sale->setGroupName($store->getGroup()->getName());
         } else {
             $websiteId = 0;
             $groupId = 0;
             $storeId = 0;
             $sale->setStoreName(__('Deleted Stores'));
         }
         $this->_groupedCollection[$websiteId][$groupId][$storeId] = $sale;
         $this->_websiteCounts[$websiteId] = isset($this->_websiteCounts[$websiteId]) ? $this->_websiteCounts[$websiteId] + 1 : 1;
     }
     return parent::_beforeToHtml();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:31,代码来源:Sales.php


示例10: getHeaderText

 /**
  * Retrieve text for header element depending on loaded page
  *
  * @return string
  */
 public function getHeaderText()
 {
     $process = $this->_coreRegistry->registry('current_index_process');
     if ($process && $process->getId()) {
         return __("'%1' Index Process Information", $process->getIndexer()->getName());
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Edit.php


示例11: _toHtml

 /**
  * Forms script response
  *
  * @return string
  */
 public function _toHtml()
 {
     $updateResult = $this->_coreRegistry->registry('composite_update_result');
     $resultJson = $this->_jsonEncoder->encode($updateResult);
     $jsVarname = $updateResult->getJsVarName();
     return $this->_jsHelper->getScript(sprintf('var %s = %s', $jsVarname, $resultJson));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:Result.php


示例12: execute

 /**
  * Apply catalog price rules to product in admin
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $product = $observer->getEvent()->getProduct();
     $storeId = $product->getStoreId();
     $date = $this->localeDate->scopeDate($storeId);
     $key = false;
     $ruleData = $this->coreRegistry->registry('rule_data');
     if ($ruleData) {
         $wId = $ruleData->getWebsiteId();
         $gId = $ruleData->getCustomerGroupId();
         $pId = $product->getId();
         $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}";
     } elseif ($product->getWebsiteId() !== null && $product->getCustomerGroupId() !== null) {
         $wId = $product->getWebsiteId();
         $gId = $product->getCustomerGroupId();
         $pId = $product->getId();
         $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}";
     }
     if ($key) {
         if (!$this->rulePricesStorage->hasRulePrice($key)) {
             $rulePrice = $this->resourceRuleFactory->create()->getRulePrice($date, $wId, $gId, $pId);
             $this->rulePricesStorage->setRulePrice($key, $rulePrice);
         }
         if ($this->rulePricesStorage->getRulePrice($key) !== false) {
             $finalPrice = min($product->getData('final_price'), $this->rulePricesStorage->getRulePrice($key));
             $product->setFinalPrice($finalPrice);
         }
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:36,代码来源:ProcessAdminFinalPriceObserver.php


示例13: getProduct

 /**
  * Get current product instance
  *
  * @return \Magento\Catalog\Model\Product
  */
 public function getProduct()
 {
     if (!is_null($this->_product)) {
         return $this->_product;
     }
     return $this->_coreRegistry->registry('product');
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:12,代码来源:Data.php


示例14: execute

 /**
  * Save order into registry to use it in the overloaded controller.
  *
  * @param EventObserver $observer
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     /* @var $order \Magento\Sales\Model\Order */
     $order = $observer->getEvent()->getData('order');
     $this->_coreRegistry->register('hss_order', $order, true);
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:SaveOrderAfterSubmitObserver.php


示例15: _toHtml

 /**
  * @return string
  */
 protected function _toHtml()
 {
     /** @var $rssObj \Magento\Rss\Model\Rss */
     $rssObj = $this->_rssFactory->create();
     $order = $this->_coreRegistry->registry('current_order');
     if (!$order) {
         return '';
     }
     $title = __('Order # %1 Notification(s)', $order->getIncrementId());
     $newUrl = $this->_urlBuilder->getUrl('sales/order/view', array('order_id' => $order->getId()));
     $rssObj->_addHeader(array('title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8'));
     /** @var $resourceModel \Magento\Rss\Model\Resource\Order */
     $resourceModel = $this->_orderFactory->create();
     $results = $resourceModel->getAllCommentCollection($order->getId());
     if ($results) {
         foreach ($results as $result) {
             $urlAppend = 'view';
             $type = $result['entity_type_code'];
             if ($type && $type != 'order') {
                 $urlAppend = $type;
             }
             $type = __(ucwords($type));
             $title = __('Details for %1 #%2', $type, $result['increment_id']);
             $description = '<p>' . __('Notified Date: %1<br/>', $this->formatDate($result['created_at'])) . __('Comment: %1<br/>', $result['comment']) . '</p>';
             $url = $this->_urlBuilder->getUrl('sales/order/' . $urlAppend, array('order_id' => $order->getId()));
             $rssObj->_addEntry(array('title' => $title, 'link' => $url, 'description' => $description));
         }
     }
     $title = __('Order #%1 created at %2', $order->getIncrementId(), $this->formatDate($order->getCreatedAt()));
     $url = $this->_urlBuilder->getUrl('sales/order/view', array('order_id' => $order->getId()));
     $description = '<p>' . __('Current Status: %1<br/>', $order->getStatusLabel()) . __('Total: %1<br/>', $order->formatPrice($order->getGrandTotal())) . '</p>';
     $rssObj->_addEntry(array('title' => $title, 'link' => $url, 'description' => $description));
     return $rssObj->createRssXml();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:37,代码来源:Status.php


示例16: execute

 /**
  * Edit sitemap
  *
  * @return void
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function execute()
 {
     // 1. Get ID and create model
     $id = $this->getRequest()->getParam('sitemap_id');
     $model = $this->_objectManager->create('Magento\\Sitemap\\Model\\Sitemap');
     // 2. Initial checking
     if ($id) {
         $model->load($id);
         if (!$model->getId()) {
             $this->messageManager->addError(__('This sitemap no longer exists.'));
             $this->_redirect('adminhtml/*/');
             return;
         }
     }
     // 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('sitemap_sitemap', $model);
     // 5. Build edit form
     $this->_initAction()->_addBreadcrumb($id ? __('Edit Sitemap') : __('New Sitemap'), $id ? __('Edit Sitemap') : __('New Sitemap'))->_addContent($this->_view->getLayout()->createBlock('Magento\\Sitemap\\Block\\Adminhtml\\Edit'));
     $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Site Map'));
     $this->_view->getPage()->getConfig()->getTitle()->prepend($model->getId() ? $model->getSitemapFilename() : __('New Site Map'));
     $this->_view->renderLayout();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:33,代码来源:Edit.php


示例17: testAddFieldsToResponseSuccess

 /**
  * Test for addFieldsToResponse method
  *
  * @return void
  */
 public function testAddFieldsToResponseSuccess()
 {
     $testData = $this->getAddFieldsToResponseSuccessTestData();
     $observerMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $orderPaymentMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment')->disableOriginalConstructor()->getMock();
     $instanceMock = $this->getMockBuilder('Magento\\Authorizenet\\Model\\Directpost')->disableOriginalConstructor()->getMock();
     $requestToAuthorizenetMock = $this->getMockBuilder('Magento\\Authorizenet\\Model\\Directpost\\Request')->disableOriginalConstructor()->setMethods(['setControllerActionName', 'setIsSecure', 'getData'])->getMock();
     $requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getControllerName'])->getMockForAbstractClass();
     $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->coreRegistryMock->expects($this->once())->method('registry')->with('directpost_order')->willReturn($orderMock);
     $orderMock->expects($this->once())->method('getId')->willReturn($testData['order.getId']);
     $orderMock->expects($this->once())->method('getPayment')->willReturn($orderPaymentMock);
     $orderPaymentMock->expects($this->once())->method('getMethod')->willReturn($testData['orderPayment.getMethod']);
     $this->paymentMock->expects($this->exactly(2))->method('getCode')->willReturn($testData['payment.getCode']);
     $observerMock->expects($this->atLeastOnce())->method('getData')->willReturnMap($testData['observer.getData']);
     $this->resultMock->expects($this->once())->method('getData')->willReturn($testData['result.getData']);
     $orderMock->expects($this->atLeastOnce())->method('getIncrementId')->willReturn($testData['order.getIncrementId']);
     $this->sessionMock->expects($this->once())->method('addCheckoutOrderIncrementId')->with($testData['session.addCheckoutOrderIncrementId']);
     $this->sessionMock->expects($this->once())->method('setLastOrderIncrementId')->with($testData['session.setLastOrderIncrementId']);
     $orderPaymentMock->expects($this->once())->method('getMethodInstance')->willReturn($instanceMock);
     $instanceMock->expects($this->once())->method('generateRequestFromOrder')->with($orderMock)->willReturn($requestToAuthorizenetMock);
     $this->actionMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
     $requestMock->expects($this->once())->method('getControllerName')->willReturn($testData['request.getControllerName']);
     $requestToAuthorizenetMock->expects($this->once())->method('setControllerActionName')->with($testData['requestToAuthorizenet.setControllerActionName']);
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
     $storeMock->expects($this->once())->method('isCurrentlySecure')->willReturn($testData['store.isCurrentlySecure']);
     $requestToAuthorizenetMock->expects($this->once())->method('setIsSecure')->with($testData['requestToAuthorizenet.setIsSecure']);
     $requestToAuthorizenetMock->expects($this->once())->method('getData')->willReturn($testData['requestToAuthorizenet.getData']);
     $this->resultMock->expects($this->once())->method('setData')->with($testData['result.setData']);
     $this->addFieldsToResponseObserver->execute($observerMock);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:37,代码来源:AddFieldsToResponseObserverTest.php


示例18: 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(RegistryConstants::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:koliaGI,项目名称:magento2,代码行数:36,代码来源:Edit.php


示例19: getProduct

 /**
  * @return Product
  */
 public function getProduct()
 {
     if (!$this->_product) {
         $this->_product = $this->_coreRegistry->registry('product');
     }
     return $this->_product;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:Description.php


示例20: execute

 /**
  * @return void
  */
 public function execute()
 {
     $this->_title->add(__('Search Terms'));
     $id = $this->getRequest()->getParam('id');
     $model = $this->_objectManager->create('Magento\\CatalogSearch\\Model\\Query');
     if ($id) {
         $model->load($id);
         if (!$model->getId()) {
             $this->messageManager->addError(__('This search no longer exists.'));
             $this->_redirect('catalog/*');
             return;
         }
     }
     // 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);
     }
     $this->_coreRegistry->register('current_catalog_search', $model);
     $this->_initAction();
     $this->_title->add($id ? $model->getQueryText() : __('New Search'));
     $this->_view->getLayout()->getBlock('head')->setCanLoadRulesJs(true);
     $this->_view->getLayout()->getBlock('adminhtml.catalog.search.edit')->setData('action', $this->getUrl('catalog/search/save'));
     $this->_addBreadcrumb($id ? __('Edit Search') : __('New Search'), $id ? __('Edit Search') : __('New Search'));
     $this->_view->renderLayout();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:29,代码来源:Edit.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Framework\StoreManagerInterface类代码示例发布时间:2022-05-23
下一篇:
PHP Framework\Profiler类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap