![]() 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-customer/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Customer\Model; use Magento\Framework\Exception\NoSuchEntityException; /** * Registry for Address models */ class AddressRegistry { /** * @var Address[] */ protected $registry = []; /** * @var AddressFactory */ protected $addressFactory; /** * @param AddressFactory $addressFactory */ public function __construct(AddressFactory $addressFactory) { $this->addressFactory = $addressFactory; } /** * Get instance of the Address Model identified by id * * @param int $addressId * @return Address * @throws NoSuchEntityException */ public function retrieve($addressId) { if (isset($this->registry[$addressId])) { return $this->registry[$addressId]; } $address = $this->addressFactory->create(); $address->load($addressId); if (!$address->getId()) { throw NoSuchEntityException::singleField('addressId', $addressId); } $this->registry[$addressId] = $address; return $address; } /** * Remove an instance of the Address Model from the registry * * @param int $addressId * @return void */ public function remove($addressId) { unset($this->registry[$addressId]); } /** * Replace existing Address Model with a new one * * @param Address $address * @return $this */ public function push(Address $address) { $this->registry[$address->getId()] = $address; return $this; } }