1 | <?php |
||
39 | trait AttributeObserverTrait |
||
40 | { |
||
41 | |||
42 | /** |
||
43 | * The ID of the attribute to create the values for. |
||
44 | * |
||
45 | * @var integer |
||
46 | */ |
||
47 | protected $attributeId; |
||
48 | |||
49 | /** |
||
50 | * The attribute code of the attribute to create the values for. |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $attributeCode; |
||
55 | |||
56 | /** |
||
57 | * The backend type of the attribute to create the values for. |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $backendType; |
||
62 | |||
63 | /** |
||
64 | * The attribute value to process. |
||
65 | * |
||
66 | * @var mixed |
||
67 | */ |
||
68 | protected $attributeValue; |
||
69 | |||
70 | /** |
||
71 | * The array with the column keys that has to be cleaned up when their values are empty. |
||
72 | * |
||
73 | * @var array |
||
74 | * @deprecated Will be removed up from version 17.0.0 |
||
75 | */ |
||
76 | protected $cleanUpEmptyColumnKeys; |
||
77 | |||
78 | /** |
||
79 | * The entity's existing attribues. |
||
80 | * |
||
81 | * @var array |
||
82 | */ |
||
83 | protected $attributes; |
||
84 | |||
85 | /** |
||
86 | * The attribute code that has to be processed. |
||
87 | * |
||
88 | * @return string The attribute code |
||
89 | */ |
||
90 | public function getAttributeCode() |
||
94 | |||
95 | /** |
||
96 | * The attribute value that has to be processed. |
||
97 | * |
||
98 | * @return string The attribute value |
||
99 | */ |
||
100 | public function getAttributeValue() |
||
104 | |||
105 | /** |
||
106 | * Remove all the empty values from the row and return the cleared row. |
||
107 | * |
||
108 | * @return array The cleared row |
||
109 | * @todo Move initialization of $this->cleanUpEmptyColumnKeys to createObserver() method and implement ObserverFactoryInterface |
||
110 | */ |
||
111 | protected function clearRow() |
||
141 | |||
142 | /** |
||
143 | * Returns the value(s) of the primary key column(s). As the primary key column can |
||
144 | * also consist of two columns, the return value can be an array also. |
||
145 | * |
||
146 | * @return mixed The primary key value(s) |
||
147 | */ |
||
148 | protected function getPrimaryKeyValue() |
||
152 | |||
153 | /** |
||
154 | * Process the observer's business logic. |
||
155 | * |
||
156 | * @return void |
||
157 | */ |
||
158 | protected function process() |
||
311 | |||
312 | /** |
||
313 | * Prepare the attributes of the entity that has to be persisted. |
||
314 | * |
||
315 | * @return array|null The prepared attributes |
||
316 | */ |
||
317 | protected function prepareAttributes() |
||
347 | |||
348 | /** |
||
349 | * Initialize the category product with the passed attributes and returns an instance. |
||
350 | * |
||
351 | * @param array $attr The category product attributes |
||
352 | * |
||
353 | * @return array The initialized category product |
||
354 | */ |
||
355 | protected function initializeAttribute(array $attr) |
||
359 | |||
360 | /** |
||
361 | * Return's the array with callbacks for the passed type. |
||
362 | * |
||
363 | * @param string $type The type of the callbacks to return |
||
364 | * |
||
365 | * @return array The callbacks |
||
366 | */ |
||
367 | protected function getCallbacksByType($type) |
||
371 | |||
372 | /** |
||
373 | * Return's mapping for the supported backend types (for the product entity) => persist methods. |
||
374 | * |
||
375 | * @return array The mapping for the supported backend types |
||
376 | */ |
||
377 | protected function getBackendTypes() |
||
381 | |||
382 | /** |
||
383 | * Return's the attributes for the attribute set of the product that has to be created. |
||
384 | * |
||
385 | * @return array The attributes |
||
386 | * @throws \Exception |
||
387 | */ |
||
388 | protected function getAttributes() |
||
392 | |||
393 | /** |
||
394 | * Intializes the existing attributes for the entity with the passed primary key. |
||
395 | * |
||
396 | * @param string $pk The primary key of the entity to load the attributes for |
||
397 | * @param integer $storeId The ID of the store view to load the attributes for |
||
398 | * |
||
399 | * @return array The entity attributes |
||
400 | */ |
||
401 | abstract protected function getAttributesByPrimaryKeyAndStoreId($pk, $storeId); |
||
402 | |||
403 | /** |
||
404 | * Return's the logger with the passed name, by default the system logger. |
||
405 | * |
||
406 | * @param string $name The name of the requested system logger |
||
407 | * |
||
408 | * @return \Psr\Log\LoggerInterface The logger instance |
||
409 | * @throws \Exception Is thrown, if the requested logger is NOT available |
||
410 | */ |
||
411 | abstract protected function getSystemLogger($name = LoggerKeys::SYSTEM); |
||
412 | |||
413 | /** |
||
414 | * Return's the PK to create the product => attribute relation. |
||
415 | * |
||
416 | * @return integer The PK to create the relation with |
||
417 | */ |
||
418 | abstract protected function getPrimaryKey(); |
||
419 | |||
420 | /** |
||
421 | * Return's the PK column name to create the product => attribute relation. |
||
422 | * |
||
423 | * @return string The PK column name |
||
424 | */ |
||
425 | abstract protected function getPrimaryKeyMemberName(); |
||
426 | |||
427 | /** |
||
428 | * Return's the column name that contains the primary key. |
||
429 | * |
||
430 | * @return string the column name that contains the primary key |
||
431 | */ |
||
432 | abstract protected function getPrimaryKeyColumnName(); |
||
433 | |||
434 | /** |
||
435 | * Queries whether or not the passed PK and store view code has already been processed. |
||
436 | * |
||
437 | * @param string $pk The PK to check been processed |
||
438 | * @param string $storeViewCode The store view code to check been processed |
||
439 | * |
||
440 | * @return boolean TRUE if the PK and store view code has been processed, else FALSE |
||
441 | */ |
||
442 | abstract protected function storeViewHasBeenProcessed($pk, $storeViewCode); |
||
443 | |||
444 | /** |
||
445 | * Persist's the passed varchar attribute. |
||
446 | * |
||
447 | * @param array $attribute The attribute to persist |
||
448 | * |
||
449 | * @return void |
||
450 | */ |
||
451 | abstract protected function persistVarcharAttribute($attribute); |
||
452 | |||
453 | /** |
||
454 | * Persist's the passed integer attribute. |
||
455 | * |
||
456 | * @param array $attribute The attribute to persist |
||
457 | * |
||
458 | * @return void |
||
459 | */ |
||
460 | abstract protected function persistIntAttribute($attribute); |
||
461 | |||
462 | /** |
||
463 | * Persist's the passed decimal attribute. |
||
464 | * |
||
465 | * @param array $attribute The attribute to persist |
||
466 | * |
||
467 | * @return void |
||
468 | */ |
||
469 | abstract protected function persistDecimalAttribute($attribute); |
||
470 | |||
471 | /** |
||
472 | * Persist's the passed datetime attribute. |
||
473 | * |
||
474 | * @param array $attribute The attribute to persist |
||
475 | * |
||
476 | * @return void |
||
477 | */ |
||
478 | abstract protected function persistDatetimeAttribute($attribute); |
||
479 | |||
480 | /** |
||
481 | * Persist's the passed text attribute. |
||
482 | * |
||
483 | * @param array $attribute The attribute to persist |
||
484 | * |
||
485 | * @return void |
||
486 | */ |
||
487 | abstract protected function persistTextAttribute($attribute); |
||
488 | |||
489 | /** |
||
490 | * Delete's the datetime attribute with the passed value ID. |
||
491 | * |
||
492 | * @param array $row The attributes of the entity to delete |
||
493 | * @param string|null $name The name of the prepared statement that has to be executed |
||
494 | * |
||
495 | * @return void |
||
496 | */ |
||
497 | abstract protected function deleteDatetimeAttribute(array $row, $name = null); |
||
498 | |||
499 | /** |
||
500 | * Delete's the decimal attribute with the passed value ID. |
||
501 | * |
||
502 | * @param array $row The attributes of the entity to delete |
||
503 | * @param string|null $name The name of the prepared statement that has to be executed |
||
504 | * |
||
505 | * @return void |
||
506 | */ |
||
507 | abstract protected function deleteDecimalAttribute(array $row, $name = null); |
||
508 | |||
509 | /** |
||
510 | * Delete's the integer attribute with the passed value ID. |
||
511 | * |
||
512 | * @param array $row The attributes of the entity to delete |
||
513 | * @param string|null $name The name of the prepared statement that has to be executed |
||
514 | * |
||
515 | * @return void |
||
516 | */ |
||
517 | abstract protected function deleteIntAttribute(array $row, $name = null); |
||
518 | |||
519 | /** |
||
520 | * Delete's the text attribute with the passed value ID. |
||
521 | * |
||
522 | * @param array $row The attributes of the entity to delete |
||
523 | * @param string|null $name The name of the prepared statement that has to be executed |
||
524 | * |
||
525 | * @return void |
||
526 | */ |
||
527 | abstract protected function deleteTextAttribute(array $row, $name = null); |
||
528 | |||
529 | /** |
||
530 | * Delete's the varchar attribute with the passed value ID. |
||
531 | * |
||
532 | * @param array $row The attributes of the entity to delete |
||
533 | * @param string|null $name The name of the prepared statement that has to be executed |
||
534 | * |
||
535 | * @return void |
||
536 | */ |
||
537 | abstract protected function deleteVarcharAttribute(array $row, $name = null); |
||
538 | |||
539 | /** |
||
540 | * Query whether or not the entity has to be processed. |
||
541 | * |
||
542 | * @param array $entity The entity to query for |
||
543 | * |
||
544 | * @return boolean TRUE if the entity has to be processed, else FALSE |
||
545 | */ |
||
546 | abstract protected function hasChanges(array $entity); |
||
547 | } |
||
548 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.