本文整理汇总了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;
}
示例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');
}
示例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);
}
示例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);
}
示例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']));
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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');
}
}
}
示例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();
}
示例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('*/*/');
}
}
}
示例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);
}
示例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;
}
示例15: tearDown
/**
* Execute per test cleanup.
*/
public function tearDown()
{
$this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID);
}