Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
AddressRegistry Class Reference

Public Member Functions

 __construct (AddressFactory $addressFactory)
 
 retrieve ($addressId)
 
 remove ($addressId)
 
 push (Address $address)
 

Protected Attributes

 $registry = []
 
 $addressFactory
 

Detailed Description

Registry for Address models

Definition at line 14 of file AddressRegistry.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( AddressFactory  $addressFactory)
Parameters
AddressFactory$addressFactory

Definition at line 29 of file AddressRegistry.php.

30  {
31  $this->addressFactory = $addressFactory;
32  }

Member Function Documentation

◆ push()

push ( Address  $address)

Replace existing Address Model with a new one

Parameters
Address$address
Returns
$this

Definition at line 72 of file AddressRegistry.php.

73  {
74  $this->registry[$address->getId()] = $address;
75  return $this;
76  }
$address
Definition: customer.php:38

◆ remove()

remove (   $addressId)

Remove an instance of the Address Model from the registry

Parameters
int$addressId
Returns
void

Definition at line 61 of file AddressRegistry.php.

62  {
63  unset($this->registry[$addressId]);
64  }

◆ retrieve()

retrieve (   $addressId)

Get instance of the Address Model identified by id

Parameters
int$addressId
Returns
Address
Exceptions
NoSuchEntityException

Definition at line 41 of file AddressRegistry.php.

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  }
$address
Definition: customer.php:38

Field Documentation

◆ $addressFactory

$addressFactory
protected

Definition at line 24 of file AddressRegistry.php.

◆ $registry

$registry = []
protected

Definition at line 19 of file AddressRegistry.php.


The documentation for this class was generated from the following file: