1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
<?php
/* --------------------------------------------------------------
CustomerAddressRepository.inc.php 2015-07-06 gm
Gambio GmbH
http://www.gambio.de
Copyright (c) 2015 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------
*/
MainFactory::load_class('CustomerAddressRepositoryInterface');
/**
* Class CustomerAddressRepository
*
* This class contains basic methods for finding, creating and deleting customer addresses
*
* @category System
* @package Customer
* @subpackage Address
* @implements CustomerAddressRepositoryInterface
*/
class CustomerAddressRepository implements CustomerAddressRepositoryInterface
{
/**
* @var CustomerAddressWriterInterface
*/
protected $customerAddressWriter;
/**
* @var CustomerAddressDeleterInterface
*/
protected $customerAddressDeleter;
/**
* @var CustomerAddressReaderInterface
*/
protected $customerAddressReader;
/**
* @var AbstractCustomerFactory
*/
protected $customerFactory;
/**
* Constructor of the class CustomerAddressRepository
*
* @param CustomerAddressWriterInterface $customerAddressWriter
* @param CustomerAddressDeleterInterface $customerAddressDeleter
* @param CustomerAddressReaderInterface $customerAddressReader
* @param AbstractCustomerFactory $customerFactory
*/
public function __construct(CustomerAddressWriterInterface $customerAddressWriter,
CustomerAddressDeleterInterface $customerAddressDeleter,
CustomerAddressReaderInterface $customerAddressReader,
AbstractCustomerFactory $customerFactory)
{
$this->customerAddressWriter = $customerAddressWriter;
$this->customerAddressDeleter = $customerAddressDeleter;
$this->customerAddressReader = $customerAddressReader;
$this->customerFactory = $customerFactory;
}
/**
* @return CustomerAddress
*/
public function getNewAddress()
{
$address = $this->customerFactory->createCustomerAddress();
$this->customerAddressWriter->write($address);
return $address;
}
/**
* Stores the customer address
*
* @param CustomerAddressInterface $address
*/
public function store(CustomerAddressInterface $address)
{
$this->customerAddressWriter->write($address);
}
/**
* Deletes the customer address
*
* @param CustomerInterface $customer
*/
public function deleteCustomerAddressesByCustomer(CustomerInterface $customer)
{
$this->customerAddressDeleter->deleteByCustomer($customer);
}
public function deleteCustomerAddress(CustomerAddressInterface $address)
{
$this->customerAddressDeleter->delete($address);
}
/**
* Get all registered address records.
*
* @return array Returns an array of CustomerAddress objects.
*/
public function getAllAddresses()
{
return $this->customerAddressReader->getAllAddresses();
}
/**
* Filter existing address records by provided string.
*
* @param string $p_keyword
*
* @return array Returns an array of CustomerAddress objects.
*/
public function filterAddresses($p_keyword)
{
return $this->customerAddressReader->filterAddresses($p_keyword);
}
/**
* Gets all customer addresses
*
* @param CustomerInterface $customer
*
* @return array of CustomerAddress objects
*/
public function getCustomerAddresses(CustomerInterface $customer)
{
$customerAddressArray = $this->customerAddressReader->findAddressesByCustomer($customer);
return $customerAddressArray;
}
/**
* @param IdType $addressBookId
*
* @return CustomerAddress
*/
public function getById(IdType $addressBookId)
{
$customerAddress = $this->customerAddressReader->findById($addressBookId);
return $customerAddress;
}
/**
* @param IdType $addressBookId
*
* @return CustomerAddress
*/
public function findById(IdType $addressBookId)
{
$customerAddress = $this->customerAddressReader->findById($addressBookId);
return $customerAddress;
}
}