1 | <?php |
||
37 | class EntityAttributeObserver extends AbstractAttributeImportObserver |
||
38 | { |
||
39 | |||
40 | /** |
||
41 | * The attribute processor instance. |
||
42 | * |
||
43 | * @var \TechDivision\Import\Attribute\Services\AttributeBunchProcessorInterface |
||
44 | */ |
||
45 | protected $attributeBunchProcessor; |
||
46 | |||
47 | /** |
||
48 | * Initializes the observer with the passed subject instance. |
||
49 | * |
||
50 | * @param \TechDivision\Import\Subjects\SubjectInterface $subject The observer's subject instance |
||
51 | * @param \TechDivision\Import\Attribute\Services\AttributeBunchProcessorInterface $attributeBunchProcessor The attribute bunch processor instance |
||
52 | */ |
||
53 | public function __construct( |
||
64 | |||
65 | /** |
||
66 | * Process the observer's business logic. |
||
67 | * |
||
68 | * @return void |
||
69 | */ |
||
70 | protected function process() |
||
84 | |||
85 | /** |
||
86 | * Prepare the attributes of the entity that has to be persisted. |
||
87 | * |
||
88 | * @return array The prepared attributes |
||
89 | */ |
||
90 | protected function prepareAttributes() |
||
119 | |||
120 | /** |
||
121 | * Initialize the attribute with the passed attributes and returns an instance. |
||
122 | * |
||
123 | * @param array $attr The attribute attributes |
||
124 | * |
||
125 | * @return array The initialized attribute |
||
126 | */ |
||
127 | protected function initializeAttribute(array $attr) |
||
131 | |||
132 | /** |
||
133 | * Return's the attribute bunch processor instance. |
||
134 | * |
||
135 | * @return \TechDivision\Import\Attribute\Services\AttributeBunchProcessorInterface The attribute bunch processor instance |
||
136 | */ |
||
137 | protected function getAttributeBunchProcessor() |
||
141 | |||
142 | /** |
||
143 | * Queries whether or not the attribute with the passed code has already been processed. |
||
144 | * |
||
145 | * @param string $attributeCode The attribute code to check |
||
146 | * |
||
147 | * @return boolean TRUE if the path has been processed, else FALSE |
||
148 | */ |
||
149 | protected function hasBeenProcessed($attributeCode) |
||
153 | |||
154 | /** |
||
155 | * Return's the ID of the attribute that has been created recently. |
||
156 | * |
||
157 | * @return integer The attribute ID |
||
158 | */ |
||
159 | protected function getLastAttributeId() |
||
163 | |||
164 | /** |
||
165 | * Return's the entity type for the passed code. |
||
166 | * |
||
167 | * @param string $entityTypeCode The entity type code |
||
168 | * |
||
169 | * @return array The requested entity type |
||
170 | * @throws \Exception Is thrown, if the entity type with the passed code is not available |
||
171 | */ |
||
172 | protected function getEntityType($entityTypeCode) |
||
176 | |||
177 | /** |
||
178 | * Return's the attribute set with the passed attribute set name. |
||
179 | * |
||
180 | * @param string $attributeSetName The name of the requested attribute set |
||
181 | * @param string $entityTypeCode The entity type code of the requested attribute set |
||
182 | * |
||
183 | * @return array The EAV attribute set |
||
184 | * @throws \Exception Is thrown, if the attribute set with the passed name is not available |
||
185 | */ |
||
186 | protected function getAttributeSetByAttributeSetNameAndEntityTypeCode($attributeSetName, $entityTypeCode) |
||
190 | |||
191 | /** |
||
192 | * Return's the attribute group with the passed attribute set/group name. |
||
193 | * |
||
194 | * @param string $entityTypeCode The entity type code of the requested attribute group |
||
195 | * @param string $attributeSetName The name of the requested attribute group's attribute set |
||
196 | * @param string $attributeGroupName The name of the requested attribute group |
||
197 | * |
||
198 | * @return array The EAV attribute group |
||
199 | * @throws \Exception Is thrown, if the attribute group with the passed attribute set/group name is not available |
||
200 | */ |
||
201 | protected function getAttributeGroupByEntityTypeCodeAndAttributeSetNameAndAttributeGroupName($entityTypeCode, $attributeSetName, $attributeGroupName) |
||
205 | |||
206 | /** |
||
207 | * Persist the passed entity attribute. |
||
208 | * |
||
209 | * @param array $entityAttribute The entity attribute to persist |
||
210 | * |
||
211 | * @return void |
||
212 | */ |
||
213 | protected function persistEntityAttribute(array $entityAttribute) |
||
217 | } |
||
218 |