1 | <?php |
||
37 | abstract class AbstractEavSubject extends AbstractSubject implements EavSubjectInterface, NumberConverterSubjectInterface |
||
38 | { |
||
39 | |||
40 | /** |
||
41 | * The trait that provides number converting functionality. |
||
42 | * |
||
43 | * @var \TechDivision\Import\Subjects\NumberConverterTrait |
||
44 | */ |
||
45 | use NumberConverterTrait; |
||
46 | |||
47 | /** |
||
48 | * The available EAV attributes, grouped by their attribute set and the attribute set name as keys. |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $attributes = array(); |
||
53 | |||
54 | /** |
||
55 | * The available user defined EAV attributes, grouped by their entity type. |
||
56 | * |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $userDefinedAttributes = array(); |
||
60 | |||
61 | /** |
||
62 | * The attribute set of the entity that has to be created. |
||
63 | * |
||
64 | * @var array |
||
65 | */ |
||
66 | protected $attributeSet = array(); |
||
67 | |||
68 | /** |
||
69 | * The available EAV attribute sets. |
||
70 | * |
||
71 | * @var array |
||
72 | */ |
||
73 | protected $attributeSets = array(); |
||
74 | |||
75 | /** |
||
76 | * The mapping for the supported backend types (for the EAV entity) => persist methods. |
||
77 | * |
||
78 | * @var array |
||
79 | */ |
||
80 | protected $backendTypes = array( |
||
81 | BackendTypeKeys::BACKEND_TYPE_DATETIME => array('persistDatetimeAttribute', 'loadDatetimeAttribute', 'deleteDatetimeAttribute'), |
||
82 | BackendTypeKeys::BACKEND_TYPE_DECIMAL => array('persistDecimalAttribute', 'loadDecimalAttribute', 'deleteDecimalAttribute'), |
||
83 | BackendTypeKeys::BACKEND_TYPE_INT => array('persistIntAttribute', 'loadIntAttribute', 'deleteIntAttribute'), |
||
84 | BackendTypeKeys::BACKEND_TYPE_TEXT => array('persistTextAttribute', 'loadTextAttribute', 'deleteTextAttribute'), |
||
85 | BackendTypeKeys::BACKEND_TYPE_VARCHAR => array('persistVarcharAttribute', 'loadVarcharAttribute', 'deleteVarcharAttribute') |
||
86 | ); |
||
87 | |||
88 | /** |
||
89 | * The mappings for the entity type code to attribute set. |
||
90 | * |
||
91 | * @var array |
||
92 | */ |
||
93 | protected $entityTypeCodeToAttributeSetMappings = array( |
||
94 | EntityTypeCodes::CATALOG_PRODUCT => EntityTypeCodes::CATALOG_PRODUCT, |
||
95 | EntityTypeCodes::CATALOG_PRODUCT_PRICE => EntityTypeCodes::CATALOG_PRODUCT, |
||
96 | EntityTypeCodes::CATALOG_PRODUCT_INVENTORY => EntityTypeCodes::CATALOG_PRODUCT, |
||
97 | EntityTypeCodes::CATALOG_CATEGORY => EntityTypeCodes::CATALOG_CATEGORY, |
||
98 | EntityTypeCodes::EAV_ATTRIBUTE => EntityTypeCodes::EAV_ATTRIBUTE, |
||
99 | EntityTypeCodes::NONE => EntityTypeCodes::NONE |
||
100 | ); |
||
101 | |||
102 | /** |
||
103 | * The default mappings for the user defined attributes, based on the attributes frontend input type. |
||
104 | * |
||
105 | * @var array |
||
106 | */ |
||
107 | protected $defaultFrontendInputCallbackMappings = array(); |
||
108 | |||
109 | /** |
||
110 | * Return's the default callback frontend input mappings for the user defined attributes. |
||
111 | * |
||
112 | * @return array The default frontend input callback mappings |
||
113 | */ |
||
114 | 22 | public function getDefaultFrontendInputCallbackMappings() |
|
118 | |||
119 | /** |
||
120 | * Intializes the previously loaded global data for exactly one bunch. |
||
121 | * |
||
122 | * @param string $serial The serial of the actual import |
||
123 | * |
||
124 | * @return void |
||
125 | */ |
||
126 | 22 | public function setUp($serial) |
|
175 | |||
176 | /** |
||
177 | * Return's mapping for the supported backend types (for the product entity) => persist methods. |
||
178 | * |
||
179 | * @return array The mapping for the supported backend types |
||
180 | */ |
||
181 | 1 | public function getBackendTypes() |
|
185 | |||
186 | /** |
||
187 | * Set's the attribute set of the product that has to be created. |
||
188 | * |
||
189 | * @param array $attributeSet The attribute set |
||
190 | * |
||
191 | * @return void |
||
192 | */ |
||
193 | 5 | public function setAttributeSet(array $attributeSet) |
|
197 | |||
198 | /** |
||
199 | * Return's the attribute set of the product that has to be created. |
||
200 | * |
||
201 | * @return array The attribute set |
||
202 | */ |
||
203 | 1 | public function getAttributeSet() |
|
207 | |||
208 | /** |
||
209 | * Cast's the passed value based on the backend type information. |
||
210 | * |
||
211 | * @param string $backendType The backend type to cast to |
||
212 | * @param mixed $value The value to be casted |
||
213 | * |
||
214 | * @return mixed The casted value |
||
215 | */ |
||
216 | 9 | public function castValueByBackendType($backendType, $value) |
|
239 | |||
240 | /** |
||
241 | * Return's the entity type code to be used. |
||
242 | * |
||
243 | * @return string The entity type code to be used |
||
244 | */ |
||
245 | 22 | public function getEntityTypeCode() |
|
259 | |||
260 | /** |
||
261 | * Return's the attribute set with the passed attribute set name. |
||
262 | * |
||
263 | * @param string $attributeSetName The name of the requested attribute set |
||
264 | * |
||
265 | * @return array The attribute set data |
||
266 | * @throws \Exception Is thrown, if the attribute set or the given entity type with the passed name is not available |
||
267 | */ |
||
268 | 3 | public function getAttributeSetByAttributeSetName($attributeSetName) |
|
296 | |||
297 | /** |
||
298 | * Return's the attributes for the attribute set of the product that has to be created. |
||
299 | * |
||
300 | * @return array The attributes |
||
301 | * @throws \Exception Is thrown, if the attribute set or the given entity type with the passed name is not available |
||
302 | */ |
||
303 | 5 | public function getAttributes() |
|
339 | |||
340 | /** |
||
341 | * Return's an array with the available user defined EAV attributes for the actual entity type. |
||
342 | * |
||
343 | * @return array The array with the user defined EAV attributes |
||
344 | */ |
||
345 | 22 | public function getEavUserDefinedAttributes() |
|
359 | |||
360 | /** |
||
361 | * Return's the EAV attribute with the passed attribute code. |
||
362 | * |
||
363 | * @param string $attributeCode The attribute code |
||
364 | * |
||
365 | * @return array The array with the EAV attribute |
||
366 | * @throws \Exception Is thrown if the attribute with the passed code is not available |
||
367 | */ |
||
368 | 2 | public function getEavAttributeByAttributeCode($attributeCode) |
|
386 | } |
||
387 |