1 | <?php |
||
37 | class MediaGalleryObserver extends AbstractProductImportObserver |
||
38 | { |
||
39 | |||
40 | /** |
||
41 | * The media gallery attribute code. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | const ATTRIBUTE_CODE = 'media_gallery'; |
||
46 | |||
47 | /** |
||
48 | * The ID of the parent product the media is related to. |
||
49 | * |
||
50 | * @var integer |
||
51 | */ |
||
52 | protected $parentId; |
||
53 | |||
54 | /** |
||
55 | * The ID of the persisted media gallery entity. |
||
56 | * |
||
57 | * @var integer |
||
58 | */ |
||
59 | protected $valueId; |
||
60 | |||
61 | /** |
||
62 | * The product media processor instance. |
||
63 | * |
||
64 | * @var \TechDivision\Import\Product\Media\Services\ProductMediaProcessorInterface |
||
65 | */ |
||
66 | protected $productMediaProcessor; |
||
67 | |||
68 | /** |
||
69 | * Initialize the observer with the passed product media processor instance. |
||
70 | * |
||
71 | * @param \TechDivision\Import\Product\Media\Services\ProductMediaProcessorInterface $productMediaProcessor The product media processor instance |
||
72 | */ |
||
73 | public function __construct(ProductMediaProcessorInterface $productMediaProcessor) |
||
77 | |||
78 | /** |
||
79 | * Return's the product media processor instance. |
||
80 | * |
||
81 | * @return \TechDivision\Import\Product\Media\Services\ProductMediaProcessorInterface The product media processor instance |
||
82 | */ |
||
83 | protected function getProductMediaProcessor() |
||
87 | |||
88 | /** |
||
89 | * Process the observer's business logic. |
||
90 | * |
||
91 | * @return array The processed row |
||
92 | */ |
||
93 | protected function process() |
||
122 | |||
123 | /** |
||
124 | * Prepare the product media gallery that has to be persisted. |
||
125 | * |
||
126 | * @return array The prepared product media gallery attributes |
||
127 | */ |
||
128 | protected function prepareProductMediaGalleryAttributes() |
||
150 | |||
151 | /** |
||
152 | * Prepare the product media gallery value to entity that has to be persisted. |
||
153 | * |
||
154 | * @return array The prepared product media gallery value to entity attributes |
||
155 | */ |
||
156 | protected function prepareProductMediaGalleryValueToEntityAttributes() |
||
167 | |||
168 | /** |
||
169 | * Initialize the product media gallery with the passed attributes and returns an instance. |
||
170 | * |
||
171 | * @param array $attr The product media gallery attributes |
||
172 | * |
||
173 | * @return array The initialized product media gallery |
||
174 | */ |
||
175 | protected function initializeProductMediaGallery(array $attr) |
||
179 | |||
180 | /** |
||
181 | * Initialize the product media gallery value to entity with the passed attributes and returns an instance. |
||
182 | * |
||
183 | * @param array $attr The product media gallery value to entity attributes |
||
184 | * |
||
185 | * @return array|null The initialized product media gallery value to entity, or NULL if the product media gallery value to entity already exists |
||
186 | */ |
||
187 | protected function initializeProductMediaGalleryValueToEntity(array $attr) |
||
191 | |||
192 | /** |
||
193 | * Map's the passed SKU of the parent product to it's PK. |
||
194 | * |
||
195 | * @param string $parentSku The SKU of the parent product |
||
196 | * |
||
197 | * @return integer The primary key used to create relations |
||
198 | */ |
||
199 | protected function mapParentSku($parentSku) |
||
203 | |||
204 | /** |
||
205 | * Set's the value ID of the created media gallery entry. |
||
206 | * |
||
207 | * @param integer $parentValueId The ID of the created media gallery entry |
||
208 | * |
||
209 | * @return void |
||
210 | */ |
||
211 | protected function setParentValueId($parentValueId) |
||
215 | |||
216 | /** |
||
217 | * Return the entity ID for the passed SKU. |
||
218 | * |
||
219 | * @param string $sku The SKU to return the entity ID for |
||
220 | * |
||
221 | * @return integer The mapped entity ID |
||
222 | * @throws \Exception Is thrown if the SKU is not mapped yet |
||
223 | */ |
||
224 | protected function mapSkuToEntityId($sku) |
||
228 | |||
229 | /** |
||
230 | * Set's the ID of the parent product to relate the variant with. |
||
231 | * |
||
232 | * @param integer $parentId The ID of the parent product |
||
233 | * |
||
234 | * @return void |
||
235 | */ |
||
236 | protected function setParentId($parentId) |
||
240 | |||
241 | /** |
||
242 | * Return's the ID of the parent product to relate the variant with. |
||
243 | * |
||
244 | * @return integer The ID of the parent product |
||
245 | */ |
||
246 | protected function getParentId() |
||
250 | |||
251 | /** |
||
252 | * Query whether or not this is the parent ID. |
||
253 | * |
||
254 | * @param integer $parentId The PK of the parent image |
||
255 | * |
||
256 | * @return boolean TRUE if the PK euqals, else FALSE |
||
257 | */ |
||
258 | protected function isParentId($parentId) |
||
262 | |||
263 | /** |
||
264 | * Query whether or not this is the parent store view code. |
||
265 | * |
||
266 | * @param string $storeViewCode The actual store view code |
||
267 | * |
||
268 | * @return boolean TRUE if the store view code equals, else FALSE |
||
269 | */ |
||
270 | protected function isParentStoreViewCode($storeViewCode) |
||
274 | |||
275 | /** |
||
276 | * Return's the default store view code. |
||
277 | * |
||
278 | * @return array The default store view code |
||
279 | */ |
||
280 | protected function getDefaultStoreViewCode() |
||
284 | |||
285 | /** |
||
286 | * Reset the position counter to 1. |
||
287 | * |
||
288 | * @return void |
||
289 | */ |
||
290 | protected function resetPositionCounter() |
||
294 | |||
295 | /** |
||
296 | * Return's the EAV attribute with the passed attribute code. |
||
297 | * |
||
298 | * @param string $attributeCode The attribute code |
||
299 | * |
||
300 | * @return array The array with the EAV attribute |
||
301 | * @throws \Exception Is thrown if the attribute with the passed code is not available |
||
302 | */ |
||
303 | protected function getEavAttributeByAttributeCode($attributeCode) |
||
307 | |||
308 | /** |
||
309 | * Persist's the passed product media gallery data and return's the ID. |
||
310 | * |
||
311 | * @param array $productMediaGallery The product media gallery data to persist |
||
312 | * |
||
313 | * @return string The ID of the persisted entity |
||
314 | */ |
||
315 | protected function persistProductMediaGallery($productMediaGallery) |
||
319 | |||
320 | /** |
||
321 | * Persist's the passed product media gallery value to entity data. |
||
322 | * |
||
323 | * @param array $productMediaGalleryValueToEntity The product media gallery value to entity data to persist |
||
324 | * |
||
325 | * @return void |
||
326 | */ |
||
327 | protected function persistProductMediaGalleryValueToEntity($productMediaGalleryValueToEntity) |
||
331 | } |
||
332 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.