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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
<?php
/* --------------------------------------------------------------
CustomerService.inc.php 2016-06-27
Gambio GmbH
http://www.gambio.de
Copyright (c) 2016 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------
*/
MainFactory::load_class('CustomerServiceInterface');
/**
* Class CustomerService
*
* This class provides methods for creating and deleting customer data
*
* @category System
* @package Customer
* @implements CustomerServiceInterface
*/
class CustomerService implements CustomerServiceInterface
{
/**
* Customer read service.
* @var CustomerReadServiceInterface
*/
protected $customerReadService;
/**
* Customer write service.
* @var CustomerWriteServiceInterface
*/
protected $customerWriteService;
/**
* Constructor of the class CustomerService.
*
* @param CustomerReadServiceInterface $customerReadService Customer read service.
* @param CustomerWriteServiceInterface $customerWriteService Customer write service.
*/
public function __construct(CustomerReadServiceInterface $customerReadService,
CustomerWriteServiceInterface $customerWriteService)
{
$this->customerReadService = $customerReadService;
$this->customerWriteService = $customerWriteService;
}
/**
* Creates a new customer with the given parameters.
*
* @param CustomerEmailInterface $email Customer's E-Mail address.
* @param CustomerPasswordInterface $password Customer's password.
* @param DateTime $dateOfBirth Customer's date of birth.
* @param CustomerVatNumberInterface $vatNumber Customer's VAT number.
* @param CustomerCallNumberInterface $telephoneNumber Customer's telephone number.
* @param CustomerCallNumberInterface $faxNumber Customer's fax number.
* @param AddressBlockInterface $addressBlock Customer's address.
* @param KeyValueCollection $addonValues Customer's additional values.
*
* @return Customer Created customer.
* @throws UnexpectedValueException On invalid arguments.
*
* TODO Replaced by VAT Check
* TODO Rename to createNewRegistree
*/
public function createNewCustomer(CustomerEmailInterface $email,
CustomerPasswordInterface $password,
DateTime $dateOfBirth,
CustomerVatNumberInterface $vatNumber,
CustomerCallNumberInterface $telephoneNumber,
CustomerCallNumberInterface $faxNumber,
AddressBlockInterface $addressBlock,
KeyValueCollection $addonValues)
{
return $this->customerWriteService->createNewRegistree($email, $password, $dateOfBirth, $vatNumber,
$telephoneNumber, $faxNumber, $addressBlock,
$addonValues);
}
/**
* Creates a new guest account with the given parameters.
*
* @param CustomerEmailInterface $email Customer's E-Mail address.
* @param DateTime $dateOfBirth Customer's date of birth.
* @param CustomerVatNumberInterface $vatNumber Customer's VAT number.
* @param CustomerCallNumberInterface $telephoneNumber Customer's telephone number.
* @param CustomerCallNumberInterface $faxNumber Customer's fax number.
* @param AddressBlockInterface $addressBlock Customer's address.
* @param KeyValueCollection $addonValues Customer's additional values.
*
* @return Customer Created guest customer.
* @throws UnexpectedValueException On invalid arguments.
*/
public function createNewGuest(CustomerEmailInterface $email,
DateTime $dateOfBirth,
CustomerVatNumberInterface $vatNumber,
CustomerCallNumberInterface $telephoneNumber,
CustomerCallNumberInterface $faxNumber,
AddressBlockInterface $addressBlock,
KeyValueCollection $addonValues)
{
return $this->customerWriteService->createNewGuest($email, $dateOfBirth, $vatNumber, $telephoneNumber,
$faxNumber, $addressBlock, $addonValues);
}
/**
* Finds a customer by its ID.
*
* @param IdType $customerId Customer's ID.
*
* @return Customer Customer.
*/
public function getCustomerById(IdType $customerId)
{
return $this->customerReadService->getCustomerById($customerId);
}
/**
* Deletes the customer by its ID.
*
* @param IdType $customerId Customer's ID.
*/
public function deleteCustomerById(IdType $customerId)
{
return $this->customerWriteService->deleteCustomerById($customerId);
}
/**
* Checks if the email address of the registree already exists.
*
* @param CustomerEmailInterface $email Customer's E-Mail address.
*
* @return bool Does the provided E-Mail address already exist?
*/
public function registreeEmailExists(CustomerEmailInterface $email)
{
return $this->customerReadService->registreeEmailExists($email);
}
/**
* Updates customer data.
*
* @param CustomerInterface $customer Customer.
*
* @return CustomerInterface Updated customer.
*/
public function updateCustomer(CustomerInterface $customer)
{
return $this->customerWriteService->updateCustomer($customer);
}
/**
* Checks if address is the default address of the customer.
*
* @param CustomerAddressInterface $customerAddress Customer's address.
*
* @return bool Is the provided address the customer's default address?
*/
public function addressIsDefaultCustomerAddress(CustomerAddressInterface $customerAddress)
{
return $this->customerReadService->addressIsDefaultCustomerAddress($customerAddress);
}
/**
* Filters customer records and returns an array with results.
*
* Example:
* $service->filterCustomers('customers_id' => 1);
*
* @param array $conditions Associative array containing the desired field and value.
* @param int $limit MySQL limit applied to the records.
* @param int $offset MySQL offset applied to the records.
*
* @return array Returns an array that contains customer objects.
*/
public function filterCustomers(array $conditions = array(), $limit = null, $offset = null)
{
return $this->customerReadService->filterCustomers($conditions, $limit, $offset);
}
}