taxRateModelFactory = $taxModelRateFactory; } /** * Register TaxRate Model to registry * * @param TaxRateModel $taxRateModel * @return void */ public function registerTaxRate(TaxRateModel $taxRateModel) { $this->taxRateRegistryById[$taxRateModel->getId()] = $taxRateModel; } /** * Retrieve TaxRate Model from registry given an id * * @param int $taxRateId * @return TaxRateModel * @throws NoSuchEntityException */ public function retrieveTaxRate($taxRateId) { if (isset($this->taxRateRegistryById[$taxRateId])) { return $this->taxRateRegistryById[$taxRateId]; } /** @var TaxRateModel $taxRateModel */ $taxRateModel = $this->taxRateModelFactory->create()->load($taxRateId); if (!$taxRateModel->getId()) { // tax rate does not exist throw NoSuchEntityException::singleField('taxRateId', $taxRateId); } $this->taxRateRegistryById[$taxRateModel->getId()] = $taxRateModel; return $taxRateModel; } /** * Remove an instance of the TaxRate Model from the registry * * @param int $taxRateId * @return void */ public function removeTaxRate($taxRateId) { unset($this->taxRateRegistryById[$taxRateId]); } }