Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddressRegistry.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Customer\Model;
8 
10 
15 {
19  protected $registry = [];
20 
24  protected $addressFactory;
25 
29  public function __construct(AddressFactory $addressFactory)
30  {
31  $this->addressFactory = $addressFactory;
32  }
33 
41  public function retrieve($addressId)
42  {
43  if (isset($this->registry[$addressId])) {
44  return $this->registry[$addressId];
45  }
46  $address = $this->addressFactory->create();
47  $address->load($addressId);
48  if (!$address->getId()) {
49  throw NoSuchEntityException::singleField('addressId', $addressId);
50  }
51  $this->registry[$addressId] = $address;
52  return $address;
53  }
54 
61  public function remove($addressId)
62  {
63  unset($this->registry[$addressId]);
64  }
65 
72  public function push(Address $address)
73  {
74  $this->registry[$address->getId()] = $address;
75  return $this;
76  }
77 }
$address
Definition: customer.php:38
__construct(AddressFactory $addressFactory)