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() |
||
124 | |||
125 | /** |
||
126 | * Prepare the product media gallery that has to be persisted. |
||
127 | * |
||
128 | * @return array The prepared product media gallery attributes |
||
129 | */ |
||
130 | protected function prepareProductMediaGalleryAttributes() |
||
152 | |||
153 | /** |
||
154 | * Prepare the product media gallery value to entity that has to be persisted. |
||
155 | * |
||
156 | * @return array The prepared product media gallery value to entity attributes |
||
157 | */ |
||
158 | protected function prepareProductMediaGalleryValueToEntityAttributes() |
||
169 | |||
170 | /** |
||
171 | * Initialize the product media gallery with the passed attributes and returns an instance. |
||
172 | * |
||
173 | * @param array $attr The product media gallery attributes |
||
174 | * |
||
175 | * @return array The initialized product media gallery |
||
176 | */ |
||
177 | protected function initializeProductMediaGallery(array $attr) |
||
181 | |||
182 | /** |
||
183 | * Initialize the product media gallery value to entity with the passed attributes and returns an instance. |
||
184 | * |
||
185 | * @param array $attr The product media gallery value to entity attributes |
||
186 | * |
||
187 | * @return array|null The initialized product media gallery value to entity, or NULL if the product media gallery value to entity already exists |
||
188 | */ |
||
189 | protected function initializeProductMediaGalleryValueToEntity(array $attr) |
||
193 | |||
194 | /** |
||
195 | * Map's the passed SKU of the parent product to it's PK. |
||
196 | * |
||
197 | * @param string $parentSku The SKU of the parent product |
||
198 | * |
||
199 | * @return integer The primary key used to create relations |
||
200 | */ |
||
201 | protected function mapParentSku($parentSku) |
||
205 | |||
206 | /** |
||
207 | * Return's the name of the created image. |
||
208 | * |
||
209 | * @return string The name of the created image |
||
210 | */ |
||
211 | protected function getParentImage() |
||
215 | |||
216 | /** |
||
217 | * Return's TRUE if the passed image is the parent one. |
||
218 | * |
||
219 | * @param string $image The imageD to check |
||
220 | * |
||
221 | * @return boolean TRUE if the passed image is the parent one |
||
222 | */ |
||
223 | protected function isParentImage($image) |
||
227 | |||
228 | /** |
||
229 | * Set's the value ID of the created media gallery entry. |
||
230 | * |
||
231 | * @param integer $parentValueId The ID of the created media gallery entry |
||
232 | * |
||
233 | * @return void |
||
234 | */ |
||
235 | protected function setParentValueId($parentValueId) |
||
239 | |||
240 | /** |
||
241 | * Return the entity ID for the passed SKU. |
||
242 | * |
||
243 | * @param string $sku The SKU to return the entity ID for |
||
244 | * |
||
245 | * @return integer The mapped entity ID |
||
246 | * @throws \Exception Is thrown if the SKU is not mapped yet |
||
247 | */ |
||
248 | protected function mapSkuToEntityId($sku) |
||
252 | |||
253 | /** |
||
254 | * Set's the ID of the parent product to relate the variant with. |
||
255 | * |
||
256 | * @param integer $parentId The ID of the parent product |
||
257 | * |
||
258 | * @return void |
||
259 | */ |
||
260 | protected function setParentId($parentId) |
||
264 | |||
265 | /** |
||
266 | * Reset the position counter to 1. |
||
267 | * |
||
268 | * @return void |
||
269 | */ |
||
270 | protected function resetPositionCounter() |
||
274 | |||
275 | /** |
||
276 | * Return's the EAV attribute with the passed attribute code. |
||
277 | * |
||
278 | * @param string $attributeCode The attribute code |
||
279 | * |
||
280 | * @return array The array with the EAV attribute |
||
281 | * @throws \Exception Is thrown if the attribute with the passed code is not available |
||
282 | */ |
||
283 | protected function getEavAttributeByAttributeCode($attributeCode) |
||
287 | |||
288 | /** |
||
289 | * Persist's the passed product media gallery data and return's the ID. |
||
290 | * |
||
291 | * @param array $productMediaGallery The product media gallery data to persist |
||
292 | * |
||
293 | * @return string The ID of the persisted entity |
||
294 | */ |
||
295 | protected function persistProductMediaGallery($productMediaGallery) |
||
299 | |||
300 | /** |
||
301 | * Persist's the passed product media gallery value to entity data. |
||
302 | * |
||
303 | * @param array $productMediaGalleryValueToEntity The product media gallery value to entity data to persist |
||
304 | * |
||
305 | * @return void |
||
306 | */ |
||
307 | protected function persistProductMediaGalleryValueToEntity($productMediaGalleryValueToEntity) |
||
311 | } |
||
312 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: