![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-catalog/Model/Locator/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Catalog\Model\Locator; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\Exception\NotFoundException; use Magento\Framework\Registry; use Magento\Store\Api\Data\StoreInterface; /** * Class RegistryLocator */ class RegistryLocator implements LocatorInterface { /** * @var Registry */ private $registry; /** * @var ProductInterface */ private $product; /** * @var StoreInterface */ private $store; /** * @param Registry $registry */ public function __construct(Registry $registry) { $this->registry = $registry; } /** * {@inheritdoc} * @throws NotFoundException */ public function getProduct() { if (null !== $this->product) { return $this->product; } if ($product = $this->registry->registry('current_product')) { return $this->product = $product; } throw new NotFoundException(__("The product wasn't registered.")); } /** * {@inheritdoc} * @throws NotFoundException */ public function getStore() { if (null !== $this->store) { return $this->store; } if ($store = $this->registry->registry('current_store')) { return $this->store = $store; } throw new NotFoundException(__("The store wasn't registered. Verify the store and try again.")); } /** * {@inheritdoc} */ public function getWebsiteIds() { return $this->getProduct()->getWebsiteIds(); } /** * {@inheritdoc} */ public function getBaseCurrencyCode() { return $this->getStore()->getBaseCurrencyCode(); } }