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


PHP Framework\Registry类代码示例

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


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


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