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


PHP Registry::unregister方法代码示例

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


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

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

示例2: tearDown

 protected function tearDown()
 {
     $this->registry->unregister('composite_configure_result_error_message');
     $this->registry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID);
     $this->registry->unregister('current_product');
     $this->registry->unregister('product');
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:CompositeTest.php

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

示例4: tearDown

 public function tearDown()
 {
     $this->_coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID);
     /** @var \Magento\Customer\Model\CustomerRegistry $customerRegistry */
     $customerRegistry = $this->_objectManager->get('Magento\\Customer\\Model\\CustomerRegistry');
     //Cleanup customer from registry
     $customerRegistry->remove(1);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:PersonalInfoTest.php

示例5: testUnregister

 public function testUnregister()
 {
     $key = 'csv_adapter';
     $valueObj = $this->getMock('\\Magento\\ImportExport\\Model\\Export\\Adapter\\Csv', [], [], '', false, false);
     $this->registry->register($key, $valueObj);
     $this->assertEquals($valueObj, $this->registry->registry($key));
     $this->registry->unregister($key);
     $this->assertNull($this->registry->registry($key));
     $this->registry->unregister($this->data['key']);
     $this->assertNull($this->registry->registry($this->data['key']));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:RegistryTest.php

示例6: getCatalogPrice

 /**
  * Minimal price for "regular" user
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param null|\Magento\Store\Model\Store $store Store view
  * @param bool $inclTax
  * @return null|float
  */
 public function getCatalogPrice(\Magento\Catalog\Model\Product $product, $store = null, $inclTax = false)
 {
     if ($store instanceof \Magento\Store\Model\Store) {
         $oldStore = $this->storeManager->getStore();
         $this->storeManager->setCurrentStore($store);
     }
     $this->coreRegistry->unregister('rule_data');
     $this->coreRegistry->register('rule_data', new \Magento\Framework\Object(array('store_id' => $product->getStoreId(), 'website_id' => $product->getWebsiteId(), 'customer_group_id' => $product->getCustomerGroupId())));
     $minPrice = $product->getPriceModel()->getTotalPrices($product, 'min', $inclTax);
     if ($store instanceof \Magento\Store\Model\Store) {
         $this->storeManager->setCurrentStore($oldStore);
     }
     return $minPrice;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:22,代码来源:CatalogPrice.php

示例7: setDeveloperRegistryBlock

 /**
  * Set developerTool Block registry
  *
  * @return bool
  */
 public function setDeveloperRegistryBlock($data)
 {
     if ($this->_coreRegistry->registry($this->_statusKey)) {
         $this->_coreRegistry->unregister($this->_statusKey);
     }
     $this->_coreRegistry->register($this->_statusKey, $data);
     return true;
 }
开发者ID:dineshmalekar,项目名称:Magento2-Developer-Debug-Tool,代码行数:13,代码来源:Data.php

示例8: setDeveloperRegistry

 /**
  * Set developerTool registry
  *
  * @return bool
  */
 public function setDeveloperRegistry($data)
 {
     $this->log($data);
     if ($this->_coreRegistry->registry($this->_dataKey)) {
         $this->_coreRegistry->unregister($this->_dataKey);
     }
     $this->_coreRegistry->register($this->_dataKey, $data);
     return true;
 }
开发者ID:hafeez3000,项目名称:Magento2-Developer-Debug-Tool,代码行数:14,代码来源:Data.php

示例9: unsetRegistryData

 /**
  * Unset registry item
  * @param array|string $unsetData
  * @return void
  */
 protected function unsetRegistryData($unsetData)
 {
     if (is_array($unsetData)) {
         foreach ($unsetData as $item) {
             $this->coreRegistry->unregister($item);
         }
     } else {
         $this->coreRegistry->unregister($unsetData);
     }
 }
开发者ID:vinai-drive-by-commits,项目名称:magento2-sample-data,代码行数:15,代码来源:Processor.php

示例10: execute

 /**
  * Address before save event handler
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_coreRegistry->registry(self::VIV_CURRENTLY_SAVED_ADDRESS)) {
         $this->_coreRegistry->unregister(self::VIV_CURRENTLY_SAVED_ADDRESS);
     }
     /** @var $customerAddress Address */
     $customerAddress = $observer->getCustomerAddress();
     if ($customerAddress->getId()) {
         $this->_coreRegistry->register(self::VIV_CURRENTLY_SAVED_ADDRESS, $customerAddress->getId());
     } else {
         $configAddressType = $this->_customerAddress->getTaxCalculationAddressType();
         $forceProcess = $configAddressType == AbstractAddress::TYPE_SHIPPING ? $customerAddress->getIsDefaultShipping() : $customerAddress->getIsDefaultBilling();
         if ($forceProcess) {
             $customerAddress->setForceProcess(true);
         } else {
             $this->_coreRegistry->register(self::VIV_CURRENTLY_SAVED_ADDRESS, 'new_address');
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:25,代码来源:BeforeAddressSaveObserver.php

示例11: deleteOrder

 /**
  * delete failed order
  *
  * @param \Magento\Sales\Model\Order $order
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function deleteOrder($order)
 {
     if ($order->canUnhold()) {
         $order->unhold();
     }
     $order->cancel();
     /* hack isSecureArea flag, otherwise actionValidator fails */
     $this->_registry->unregister('isSecureArea');
     $this->_registry->register('isSecureArea', true);
     $order->delete();
 }
开发者ID:wirecard,项目名称:magento2-wcp,代码行数:18,代码来源:OrderManagement.php

示例12: execute

 /**
  * Dispatch request
  *
  * @return \Magento\Framework\Controller\ResultInterface|ResponseInterface
  * @throws \Magento\Framework\Exception\NotFoundException
  */
 public function execute()
 {
     $id = $this->getRequest()->getParam('cadou_id');
     $model = $this->_objectManager->create('Alin\\Cadou\\Model\\Cadou');
     if ($id) {
         $model->load($id);
         if (!$model->getId()) {
             $this->messageManager->addError(__('This cadou no longer exists.'));
             /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
             $resultRedirect = $this->resultRedirectFactory->create();
             return $resultRedirect->setPath('*/*/');
         } else {
             $model->delete();
             $this->_coreRegistry->unregister('cadou', $model);
             $this->messageManager->addSuccess(__('The selected record has been deleted.'));
             $resultRedirect = $this->resultRedirectFactory->create();
             return $resultRedirect->setPath('*/*/');
         }
     }
 }
开发者ID:alinmiron,项目名称:alin-cadou,代码行数:26,代码来源:Delete.php

示例13: testToHtmlNoCustomerId

 /**
  * No data fixture nor is there a customer Id set in the registry.
  */
 public function testToHtmlNoCustomerId()
 {
     $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID);
     $customerData['account'] = array(Customer::FIRSTNAME => 'John', Customer::LASTNAME => 'Doe', Customer::EMAIL => 'john.doe@gmail.com', Customer::GROUP_ID => 1, Customer::WEBSITE_ID => 1);
     $customerData['address'] = array();
     $this->context->getBackendSession()->setCustomerData($customerData);
     $html = $this->block->toHtml();
     $this->assertNotContains('name="cart" title="Shopping Cart"', $html);
     $this->assertNotContains('name="wishlist" title="Wishlist"', $html);
     $this->assertStringMatchesFormat('%a name="account[firstname]" %s value="John" %a', $html);
     $this->assertStringMatchesFormat('%a name="account[lastname]" %s value="Doe" %a', $html);
     $this->assertStringMatchesFormat('%a name="account[email]" %s value="john.doe@gmail.com" %a', $html);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:TabsTest.php

示例14: setClient

 /**
  * Set Google Content Client Instance
  *
  * @param \Zend_Http_Client $client
  * @return $this
  */
 public function setClient($client)
 {
     $this->_coreRegistry->unregister($this->_clientRegistryId);
     $this->_coreRegistry->register($this->_clientRegistryId, $client);
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:Service.php

示例15: tearDown

 /**
  * Execute per test cleanup.
  */
 public function tearDown()
 {
     $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:7,代码来源:CartTest.php


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