1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Customer\Address\Assemblers\CustomerAttributeAssembler |
5
|
|
|
* |
6
|
|
|
* PHP version 7 |
7
|
|
|
* |
8
|
|
|
* @author Tim Wagner <[email protected]> |
9
|
|
|
* @copyright 2018 TechDivision GmbH <[email protected]> |
10
|
|
|
* @license https://opensource.org/licenses/MIT |
11
|
|
|
* @link https://github.com/techdivision/import-customer-address |
12
|
|
|
* @link http://www.techdivision.com |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace TechDivision\Import\Customer\Address\Assemblers; |
16
|
|
|
|
17
|
|
|
use TechDivision\Import\Customer\Address\Utils\MemberNames; |
18
|
|
|
use TechDivision\Import\Customer\Address\Repositories\CustomerAddressDatetimeRepositoryInterface; |
19
|
|
|
use TechDivision\Import\Customer\Address\Repositories\CustomerAddressDecimalRepositoryInterface; |
20
|
|
|
use TechDivision\Import\Customer\Address\Repositories\CustomerAddressIntRepositoryInterface; |
21
|
|
|
use TechDivision\Import\Customer\Address\Repositories\CustomerAddressTextRepositoryInterface; |
22
|
|
|
use TechDivision\Import\Customer\Address\Repositories\CustomerAddressVarcharRepositoryInterface; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Assembler implementation that provides functionality to assemble customer address attribute data. |
26
|
|
|
* |
27
|
|
|
* @author Tim Wagner <[email protected]> |
28
|
|
|
* @copyright 2018 TechDivision GmbH <[email protected]> |
29
|
|
|
* @license https://opensource.org/licenses/MIT |
30
|
|
|
* @link https://github.com/techdivision/import-customer-address |
31
|
|
|
* @link http://www.techdivision.com |
32
|
|
|
*/ |
33
|
|
|
class CustomerAddressAttributeAssembler implements CustomerAddressAttributeAssemblerInterface |
34
|
|
|
{ |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* The customer address datetime repository instance. |
38
|
|
|
* |
39
|
|
|
* @var \TechDivision\Import\Customer\Address\Repositories\CustomerAddressDatetimeRepositoryInterface |
40
|
|
|
*/ |
41
|
|
|
protected $customerAddressDatetimeRepository; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* The customer address decimal repository instance. |
45
|
|
|
* |
46
|
|
|
* @var \TechDivision\Import\Customer\Address\Repositories\CustomerAddressDecimalRepositoryInterface |
47
|
|
|
*/ |
48
|
|
|
protected $customerAddressDecimalRepository; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* The customer address integer repository instance. |
52
|
|
|
* |
53
|
|
|
* @var \TechDivision\Import\Customer\Address\Repositories\CustomerAddressIntRepositoryInterface |
54
|
|
|
*/ |
55
|
|
|
protected $customerAddressIntRepository; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* The customer address text repository instance. |
59
|
|
|
* |
60
|
|
|
* @var \TechDivision\Import\Customer\Address\Repositories\CustomerAddressTextRepositoryInterface |
61
|
|
|
*/ |
62
|
|
|
protected $customerAddressTextRepository; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* The customer address varchar repository instance. |
66
|
|
|
* |
67
|
|
|
* @var \TechDivision\Import\Customer\Address\Repositories\CustomerAddressVarcharRepositoryInterface |
68
|
|
|
*/ |
69
|
|
|
protected $customerAddressVarcharRepository; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Initializes the assembler with the necessary repositories. |
73
|
|
|
* |
74
|
|
|
* @param \TechDivision\Import\Customer\Address\Repositories\CustomerAddressDatetimeRepositoryInterface $customerAddressDatetimeRepository The customer address datetime repository instance |
75
|
|
|
* @param \TechDivision\Import\Customer\Address\Repositories\CustomerAddressDecimalRepositoryInterface $customerAddressDecimalRepository The customer address decimal repository instance |
76
|
|
|
* @param \TechDivision\Import\Customer\Address\Repositories\CustomerAddressIntRepositoryInterface $customerAddressIntRepository The customer address integer repository instance |
77
|
|
|
* @param \TechDivision\Import\Customer\Address\Repositories\CustomerAddressTextRepositoryInterface $customerAddressTextRepository The customer address text repository instance |
78
|
|
|
* @param \TechDivision\Import\Customer\Address\Repositories\CustomerAddressVarcharRepositoryInterface $customerAddressVarcharRepository The customer address varchar repository instance |
79
|
|
|
*/ |
80
|
|
|
public function __construct( |
81
|
|
|
CustomerAddressDatetimeRepositoryInterface $customerAddressDatetimeRepository, |
82
|
|
|
CustomerAddressDecimalRepositoryInterface $customerAddressDecimalRepository, |
83
|
|
|
CustomerAddressIntRepositoryInterface $customerAddressIntRepository, |
84
|
|
|
CustomerAddressTextRepositoryInterface $customerAddressTextRepository, |
85
|
|
|
CustomerAddressVarcharRepositoryInterface $customerAddressVarcharRepository |
86
|
|
|
) { |
87
|
|
|
$this->customerAddressDatetimeRepository = $customerAddressDatetimeRepository; |
88
|
|
|
$this->customerAddressDecimalRepository = $customerAddressDecimalRepository; |
89
|
|
|
$this->customerAddressIntRepository = $customerAddressIntRepository; |
90
|
|
|
$this->customerAddressTextRepository = $customerAddressTextRepository; |
91
|
|
|
$this->customerAddressVarcharRepository = $customerAddressVarcharRepository; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Intializes the existing attributes for the entity with the passed entity ID. |
96
|
|
|
* |
97
|
|
|
* @param integer $entityId The entity ID of the entity to load the attributes for |
98
|
|
|
* |
99
|
|
|
* @return array The entity attributes |
100
|
|
|
*/ |
101
|
|
|
public function getCustomerAddressAttributesByEntityId($entityId) |
102
|
|
|
{ |
103
|
|
|
|
104
|
|
|
// initialize the array for the attributes |
105
|
|
|
$attributes = array(); |
106
|
|
|
|
107
|
|
|
// load the datetime attributes |
108
|
|
|
foreach ($this->customerAddressDatetimeRepository->findAllByEntityId($entityId) as $attribute) { |
109
|
|
|
$attributes[$attribute[MemberNames::ATTRIBUTE_ID]] = $attribute; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
// load the decimal attributes |
113
|
|
|
foreach ($this->customerAddressDecimalRepository->findAllByEntityId($entityId) as $attribute) { |
114
|
|
|
$attributes[$attribute[MemberNames::ATTRIBUTE_ID]] = $attribute; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
// load the integer attributes |
118
|
|
|
foreach ($this->customerAddressIntRepository->findAllByEntityId($entityId) as $attribute) { |
119
|
|
|
$attributes[$attribute[MemberNames::ATTRIBUTE_ID]] = $attribute; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
// load the text attributes |
123
|
|
|
foreach ($this->customerAddressTextRepository->findAllByEntityId($entityId) as $attribute) { |
124
|
|
|
$attributes[$attribute[MemberNames::ATTRIBUTE_ID]] = $attribute; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
// load the varchar attributes |
128
|
|
|
foreach ($this->customerAddressVarcharRepository->findAllByEntityId($entityId) as $attribute) { |
129
|
|
|
$attributes[$attribute[MemberNames::ATTRIBUTE_ID]] = $attribute; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
// return the array with the attributes |
133
|
|
|
return $attributes; |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|