1 | <?php |
||
36 | class EntityAttributeObserver extends AbstractAttributeImportObserver |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * The attribute processor instance. |
||
41 | * |
||
42 | * @var \TechDivision\Import\Attribute\Services\AttributeBunchProcessorInterface |
||
43 | */ |
||
44 | protected $attributeBunchProcessor; |
||
45 | |||
46 | /** |
||
47 | * Initializes the observer with the passed subject instance. |
||
48 | * |
||
49 | * @param \TechDivision\Import\Attribute\Services\AttributeBunchProcessorInterface $attributeBunchProcessor The attribute bunch processor instance |
||
50 | */ |
||
51 | public function __construct(AttributeBunchProcessorInterface $attributeBunchProcessor) |
||
55 | |||
56 | /** |
||
57 | * Process the observer's business logic. |
||
58 | * |
||
59 | * @return void |
||
60 | */ |
||
61 | protected function process() |
||
105 | |||
106 | /** |
||
107 | * Prepare the attributes of the entity that has to be persisted. |
||
108 | * |
||
109 | * @return array The prepared attributes |
||
110 | */ |
||
111 | protected function prepareAttributes() |
||
135 | |||
136 | /** |
||
137 | * Initialize the attribute with the passed attributes and returns an instance. |
||
138 | * |
||
139 | * @param array $attr The attribute attributes |
||
140 | * |
||
141 | * @return array The initialized attribute |
||
142 | */ |
||
143 | protected function initializeAttribute(array $attr) |
||
147 | |||
148 | /** |
||
149 | * Return's the attribute bunch processor instance. |
||
150 | * |
||
151 | * @return \TechDivision\Import\Attribute\Services\AttributeBunchProcessorInterface The attribute bunch processor instance |
||
152 | */ |
||
153 | protected function getAttributeBunchProcessor() |
||
157 | |||
158 | /** |
||
159 | * Queries whether or not the attribute with the passed code has already been processed. |
||
160 | * |
||
161 | * @param string $attributeCode The attribute code to check |
||
162 | * |
||
163 | * @return boolean TRUE if the path has been processed, else FALSE |
||
164 | */ |
||
165 | protected function hasBeenProcessed($attributeCode) |
||
169 | |||
170 | /** |
||
171 | * Return's the ID of the attribute that has been created recently. |
||
172 | * |
||
173 | * @return integer The attribute ID |
||
174 | */ |
||
175 | protected function getLastAttributeId() |
||
179 | |||
180 | /** |
||
181 | * Return's the entity type for the passed code. |
||
182 | * |
||
183 | * @param string $entityTypeCode The entity type code |
||
184 | * |
||
185 | * @return array The requested entity type |
||
186 | * @throws \Exception Is thrown, if the entity type with the passed code is not available |
||
187 | */ |
||
188 | protected function getEntityType($entityTypeCode) |
||
192 | |||
193 | /** |
||
194 | * Return's the attribute set with the passed attribute set name. |
||
195 | * |
||
196 | * @param string $attributeSetName The name of the requested attribute set |
||
197 | * @param string $entityTypeCode The entity type code of the requested attribute set |
||
198 | * |
||
199 | * @return array The EAV attribute set |
||
200 | * @throws \Exception Is thrown, if the attribute set with the passed name is not available |
||
201 | */ |
||
202 | protected function getAttributeSetByAttributeSetNameAndEntityTypeCode($attributeSetName, $entityTypeCode) |
||
206 | |||
207 | /** |
||
208 | * Return's the attribute group with the passed attribute set/group name. |
||
209 | * |
||
210 | * @param string $entityTypeCode The entity type code of the requested attribute group |
||
211 | * @param string $attributeSetName The name of the requested attribute group's attribute set |
||
212 | * @param string $attributeGroupName The name of the requested attribute group |
||
213 | * |
||
214 | * @return array The EAV attribute group |
||
215 | * @throws \Exception Is thrown, if the attribute group with the passed attribute set/group name is not available |
||
216 | */ |
||
217 | protected function getAttributeGroupByEntityTypeCodeAndAttributeSetNameAndAttributeGroupName($entityTypeCode, $attributeSetName, $attributeGroupName) |
||
221 | |||
222 | /** |
||
223 | * Persist the passed entity attribute. |
||
224 | * |
||
225 | * @param array $entityAttribute The entity attribute to persist |
||
226 | * |
||
227 | * @return void |
||
228 | */ |
||
229 | protected function persistEntityAttribute(array $entityAttribute) |
||
233 | } |
||
234 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: