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


PHP Registry::register方法代码示例

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


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

示例1: execute

 /**
  * Edit
  *
  * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function execute()
 {
     // \Zend_Debug::dump($this->getRequest()->getFullActionName());
     $_modelKey = 'Swissup\\Email\\Model\\Service';
     $id = $this->getRequest()->getParam('id');
     $model = $this->_objectManager->create($_modelKey);
     if ($id) {
         $model->load($id);
         if (!$model->getId()) {
             $this->messageManager->addError(__('This item no longer exists.'));
             /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
             $resultRedirect = $this->resultRedirectFactory->create();
             return $resultRedirect->setPath('*/*/');
         }
     }
     $data = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getFormData(true);
     if (!empty($data)) {
         $model->setData($data);
     }
     $this->coreRegistry->register('email_service', $model);
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->_initAction();
     $resultPage->addBreadcrumb($id ? __('Edit') : __('New'), $id ? __('Edit') : __('New'));
     $resultPage->getConfig()->getTitle()->prepend(__('Emails Services'));
     $resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getTitle() : __('New'));
     return $resultPage;
 }
开发者ID:swissup,项目名称:email,代码行数:33,代码来源:Edit.php

示例2: build

 /**
  * Build product based on user request
  *
  * @param RequestInterface $request
  * @return \Magento\Catalog\Model\Product
  */
 public function build(RequestInterface $request)
 {
     $productId = (int) $request->getParam('id');
     /** @var $product \Magento\Catalog\Model\Product */
     $product = $this->productFactory->create();
     $product->setStoreId($request->getParam('store', 0));
     $typeId = $request->getParam('type');
     if (!$productId && $typeId) {
         $product->setTypeId($typeId);
     }
     $product->setData('_edit_mode', true);
     if ($productId) {
         try {
             $product->load($productId);
         } catch (\Exception $e) {
             $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE);
             $this->logger->critical($e);
         }
     }
     $setId = (int) $request->getParam('set');
     if ($setId) {
         $product->setAttributeSetId($setId);
     }
     $this->registry->register('product', $product);
     $this->registry->register('current_product', $product);
     $this->wysiwygConfig->setStoreId($request->getParam('store'));
     return $product;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:34,代码来源:Builder.php

示例3: toOptionArray

 /**
  * Get options.
  *
  * @return array
  */
 public function toOptionArray()
 {
     $fields = [];
     $fields[] = ['value' => '0', 'label' => '-- Disabled --'];
     $websiteName = $this->request->getParam('website', false);
     $website = $websiteName ? $this->storeManager->getWebsite($websiteName) : 0;
     if ($this->helper->isEnabled($website)) {
         $savedPrograms = $this->registry->registry('programs');
         //get saved datafileds from registry
         if (is_array($savedPrograms)) {
             $programs = $savedPrograms;
         } else {
             //grab the datafields request and save to register
             $client = $this->helper->getWebsiteApiClient($website);
             $programs = $client->getPrograms();
             $this->registry->unregister('programs');
             $this->registry->register('programs', $programs);
         }
         //set the api error message for the first option
         if (isset($programs->message)) {
             //message
             $fields[] = ['value' => 0, 'label' => $programs->message];
         } elseif (!empty($programs)) {
             //loop for all programs option
             foreach ($programs as $program) {
                 if (isset($program->id) && $program->status == 'Active') {
                     //@codingStandardsIgnoreStart
                     $fields[] = ['value' => $program->id, 'label' => addslashes($program->name)];
                     //@codingStandardsIgnoreEnd
                 }
             }
         }
     }
     return $fields;
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:40,代码来源:Program.php

示例4: execute

 /**
  *
  * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function execute()
 {
     $id = $this->getRequest()->getParam('email_contact_id');
     $model = $this->_contactFactory->create();
     //check the param contact id
     if ($id) {
         //load the and check the contact model
         $model->load($id);
         if (!$model->getId()) {
             $this->messageManager->addError(__('This contact no longer exists.'));
             /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
             $resultRedirect = $this->resultRedirectFactory->create();
             return $resultRedirect->setPath('*/*/');
         }
     }
     $data = $this->_sessionFactory->create()->getFormData(true);
     if (!empty($data)) {
         $model->setData($data);
     }
     $this->_coreRegistry->register('email_contact', $model);
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->_initAction();
     $resultPage->addBreadcrumb($id ? __('Edit Contact ') : __('New Contact'), $id ? __('Edit Contact ') : __('New Contact'));
     $resultPage->getConfig()->getTitle()->prepend(__('Contacts'));
     $resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getTitle() : __('New Contacts'));
     return $resultPage;
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:32,代码来源:Edit.php

示例5: execute

 /**
  * Get associated grouped products grid popup
  *
  * @return void
  */
 public function execute()
 {
     $productId = (int) $this->getRequest()->getParam('id');
     /** @var $product \Magento\Catalog\Model\Product */
     $product = $this->factory->create();
     $product->setStoreId($this->getRequest()->getParam('store', 0));
     $typeId = $this->getRequest()->getParam('type');
     if (!$productId && $typeId) {
         $product->setTypeId($typeId);
     }
     $product->setData('_edit_mode', true);
     if ($productId) {
         try {
             $product->load($productId);
         } catch (\Exception $e) {
             $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE);
             $this->logger->critical($e);
         }
     }
     $setId = (int) $this->getRequest()->getParam('set');
     if ($setId) {
         $product->setAttributeSetId($setId);
     }
     $this->registry->register('current_product', $product);
     $this->_view->loadLayout(false);
     $this->_view->renderLayout();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:32,代码来源:Popup.php

示例6: replaceCodeInRegistry

 public function replaceCodeInRegistry($code)
 {
     if ($this->_registry->registry(static::REG_REFERRAL_CODE)) {
         $this->_registry->unregister(static::REG_REFERRAL_CODE);
     }
     $this->_registry->register(static::REG_REFERRAL_CODE, $code);
 }
开发者ID:praxigento,项目名称:mobi_mod_mage2_downline,代码行数:7,代码来源:Referral.php

示例7: execute

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

示例8: execute

 /**
  * Edit Synonym Group
  *
  * @return \Magento\Framework\Controller\ResultInterface
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function execute()
 {
     // 1. Get ID and create model
     $groupId = $this->getRequest()->getParam('group_id');
     /** @var \Magento\Search\Api\Data\SynonymGroupInterface $synGroup */
     $synGroup = $this->synGroupRepository->get($groupId);
     // 2. Initial checking
     if ($groupId && !$synGroup->getGroupId()) {
         $this->messageManager->addError(__('This synonyms group 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->_session->getFormData(true);
     if (!empty($data)) {
         $synGroup->setGroupId($data['group_id']);
         $synGroup->setStoreId($data['store_id']);
         $synGroup->setWebsiteId($data['website_id']);
         $synGroup->setSynonymGroup($data['synonyms']);
     }
     // 4. Register model to use later in save
     $this->registry->register(\Magento\Search\Controller\RegistryConstants::SEARCH_SYNONYMS, $synGroup);
     // 5. Build edit synonyms group form
     $resultPage = $this->pageBuilder->build();
     $resultPage->addBreadcrumb($groupId ? __('Edit Synonym Group') : __('New Synonym Group'), $groupId ? __('Edit Synonym Group') : __('New Synonym Group'));
     $resultPage->getConfig()->getTitle()->prepend(__('Synonym Group'));
     $resultPage->getConfig()->getTitle()->prepend($synGroup->getGroupId() ? $synGroup->getSynonymGroup() : __('New Synonym Group'));
     return $resultPage;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:36,代码来源:Edit.php

示例9: toOptionArray

 /**
  *  Datafields option.
  *
  * @return array
  */
 public function toOptionArray()
 {
     $fields = [];
     //default data option
     $fields[] = ['value' => '0', 'label' => '-- Please Select --'];
     $apiEnabled = $this->helper->isEnabled($this->helper->getWebsite());
     if ($apiEnabled) {
         $savedDatafields = $this->registry->registry('datafields');
         //get saved datafileds from registry
         if ($savedDatafields) {
             $datafields = $savedDatafields;
         } else {
             //grab the datafields request and save to register
             $client = $this->helper->getWebsiteApiClient();
             $datafields = $client->getDatafields();
             $this->registry->register('datafields', $datafields);
         }
         //set the api error message for the first option
         if (isset($datafields->message)) {
             //message
             $fields[] = ['value' => 0, 'label' => $datafields->message];
         } else {
             //loop for all datafields option
             foreach ($datafields as $datafield) {
                 if (isset($datafield->name)) {
                     $fields[] = ['value' => $datafield->name, 'label' => $datafield->name];
                 }
             }
         }
     }
     return $fields;
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:37,代码来源:Datafields.php

示例10: execute

 /**
  * Edit grid record
  *
  * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function execute()
 {
     $id = $this->getRequest()->getParam('element_id');
     $model = $this->_objectManager->create('OuterEdge\\Layout\\Model\\Elements');
     if ($id) {
         $model->load($id);
         if (!$model->getId()) {
             $this->messageManager->addError(__('This element record no longer exists.'));
             /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
             $resultRedirect = $this->resultRedirectFactory->create();
             return $resultRedirect->setPath('*/*/');
         }
     }
     //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);
     }
     //Register model to use later in blocks
     $this->_coreRegistry->register('layout_elements_form_data', $model);
     //Build edit form
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->_initAction();
     $resultPage->addBreadcrumb($id ? __('Edit Element') : __('New Element'), $id ? __('Edit Element') : __('New Element'));
     $resultPage->getConfig()->getTitle()->prepend(__('Element'));
     $resultPage->getConfig()->getTitle()->prepend($model->getId() ? $model->getTitle() : __('New Element'));
     return $resultPage;
 }
开发者ID:outeredge,项目名称:magento-layout-module,代码行数:34,代码来源:Edit.php

示例11: toOptionArray

 /**
  * Retrieve list of options.
  *
  * @return array
  */
 public function toOptionArray()
 {
     $fields = [];
     // Add a "Do Not Map" Option
     $fields[] = ['value' => 0, 'label' => '-- Please Select --'];
     $apiEnabled = $this->helper->isEnabled($this->helper->getWebsite());
     if ($apiEnabled) {
         $savedAddressbooks = $this->registry->registry('addressbooks');
         if ($savedAddressbooks) {
             $addressBooks = $savedAddressbooks;
         } else {
             $client = $this->helper->getWebsiteApiClient();
             //make an api call an register the addressbooks
             $addressBooks = $client->getAddressBooks();
             if ($addressBooks) {
                 $this->registry->register('addressbooks', $addressBooks);
             }
         }
         //set up fields with book id and label
         foreach ($addressBooks as $book) {
             if (isset($book->id)) {
                 $fields[] = ['value' => (string) $book->id, 'label' => (string) $book->name];
             }
         }
     }
     return $fields;
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:32,代码来源:Addressbooks.php

示例12: execute

 /**
  * Edit Newsletter Template
  *
  * @return void
  */
 public function execute()
 {
     $model = $this->_objectManager->create('Magento\\Newsletter\\Model\\Template');
     $id = $this->getRequest()->getParam('id');
     if ($id) {
         $model->load($id);
     }
     $this->_coreRegistry->register('_current_template', $model);
     $this->_view->loadLayout();
     $this->_setActiveMenu('Magento_Newsletter::newsletter_template');
     if ($model->getId()) {
         $breadcrumbTitle = __('Edit Template');
         $breadcrumbLabel = $breadcrumbTitle;
     } else {
         $breadcrumbTitle = __('New Template');
         $breadcrumbLabel = __('Create Newsletter Template');
     }
     $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Newsletter Templates'));
     $this->_view->getPage()->getConfig()->getTitle()->prepend($model->getId() ? $model->getTemplateCode() : __('New Template'));
     $this->_addBreadcrumb($breadcrumbLabel, $breadcrumbTitle);
     // restore data
     $values = $this->_getSession()->getData('newsletter_template_form_data', true);
     if ($values) {
         $model->addData($values);
     }
     $this->_view->renderLayout();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:32,代码来源:Edit.php

示例13: execute

 /**
  * Execute method.
  *
  * @param \Magento\Framework\Event\Observer $observer
  *
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     try {
         if (!$this->registry->registry('core_config_data_save_after_done')) {
             if ($groups = $observer->getEvent()->getConfigData()->getGroups()) {
                 if (isset($groups['catalog_sync']['fields']['catalog_values']['value'])) {
                     $configAfter = $groups['catalog_sync']['fields']['catalog_values']['value'];
                     $configBefore = $this->registry->registry('core_config_data_save_before');
                     if ($configAfter != $configBefore) {
                         //reset catalog to re-import
                         $this->connectorCatalogFactory->create()->reset();
                     }
                     $this->registry->register('core_config_data_save_after_done', true);
                 }
             }
         }
         if (!$this->registry->registry('core_config_data_save_after_done_status')) {
             if ($groups = $observer->getEvent()->getConfigData()->getGroups()) {
                 if (isset($groups['data_fields']['fields']['order_statuses']['value'])) {
                     $configAfter = $groups['data_fields']['fields']['order_statuses']['value'];
                     $configBefore = $this->registry->registry('core_config_data_save_before_status');
                     if ($configAfter != $configBefore) {
                         //reset all contacts
                         $this->connectorContactFactory->create()->resetAllContacts();
                     }
                     $this->registry->register('core_config_data_save_after_done_status', true);
                 }
             }
         }
     } catch (\Exception $e) {
         $this->helper->debug((string) $e, []);
     }
     return $this;
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:41,代码来源:ResetCatalogContactImport.php

示例14: 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

示例15: afterGenerateXml

 /**
  * After generate Xml
  *
  * @param \Magento\Framework\View\LayoutInterface $subject
  * @param \Magento\Framework\View\LayoutInterface $result
  * @return \Magento\Framework\View\LayoutInterface
  */
 public function afterGenerateXml(\Magento\Framework\View\LayoutInterface $subject, $result)
 {
     if (!$this->registry->registry(self::REGISTRY_KEY)) {
         $this->registry->register(self::REGISTRY_KEY, $this->customerSession->getCustomer());
     }
     return $result;
 }
开发者ID:rejoiner,项目名称:magento2-plugin,代码行数:14,代码来源:DepersonalizePlugin.php


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