![]() 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-tax/Block/Adminhtml/Rate/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Tax\Block\Adminhtml\Rate; use Magento\Tax\Controller\RegistryConstants; /** * Tax Rate Titles Renderer * * @author Magento Core Team <[email protected]> */ class Title extends \Magento\Framework\View\Element\Template { /** * @var array */ protected $_titles; /** * @var string */ protected $_template = 'Magento_Tax::rate/title.phtml'; /** * @var \Magento\Store\Model\StoreFactory */ protected $_storeFactory; /** * @var \Magento\Framework\Registry */ protected $_coreRegistry; /** * @var \Magento\Tax\Api\TaxRateRepositoryInterface */ protected $_taxRateRepository; /** * Initialize dependencies * * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Store\Model\StoreFactory $storeFactory * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Tax\Api\TaxRateRepositoryInterface $taxRateRepository * @param array $data */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Store\Model\StoreFactory $storeFactory, \Magento\Framework\Registry $coreRegistry, \Magento\Tax\Api\TaxRateRepositoryInterface $taxRateRepository, array $data = [] ) { $this->_coreRegistry = $coreRegistry; $this->_taxRateRepository = $taxRateRepository; $this->_storeFactory = $storeFactory; parent::__construct($context, $data); } /** * Return the tax rate titles associated with a store view. * * @return array */ public function getTitles() { if ($this->_titles === null) { $this->_titles = []; $taxRateId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_TAX_RATE_ID); $titles = []; if ($taxRateId) { $rate = $this->_taxRateRepository->get($taxRateId); $titles = $rate->getTitles(); } foreach ($titles as $title) { $this->_titles[$title->getStoreId()] = $title->getValue(); } foreach ($this->getStores() as $store) { if (!isset($this->_titles[$store->getId()])) { $this->_titles[$store->getId()] = ''; } } } return $this->_titles; } /** * @return mixed */ public function getStores() { $stores = $this->getData('stores'); if ($stores === null) { $stores = $this->_storeFactory->create()->getResourceCollection()->setLoadDefault(false)->load(); $this->setData('stores', $stores); } return $stores; } }