1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Attribute\Observers\AbstractAttributeImportObserver |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/techdivision/import-attribute |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Attribute\Observers; |
22
|
|
|
|
23
|
|
|
use TechDivision\Import\Observers\AbstractObserver; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Abstract attribute observer that handles the process to import attribute bunches. |
27
|
|
|
* |
28
|
|
|
* @author Tim Wagner <[email protected]> |
29
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
31
|
|
|
* @link https://github.com/techdivision/import-attribute |
32
|
|
|
* @link http://www.techdivision.com |
33
|
|
|
*/ |
34
|
|
|
abstract class AbstractAttributeImportObserver extends AbstractObserver implements AttributeImportObserverInterface |
35
|
|
|
{ |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Will be invoked by the action on the events the listener has been registered for. |
39
|
|
|
* |
40
|
|
|
* @param array $row The row to handle |
41
|
|
|
* |
42
|
|
|
* @return array The modified row |
43
|
|
|
* @see \TechDivision\Import\Product\Observers\ImportObserverInterface::handle() |
44
|
|
|
*/ |
45
|
|
|
public function handle(array $row) |
46
|
|
|
{ |
47
|
|
|
|
48
|
|
|
// initialize the row |
49
|
|
|
$this->setRow($row); |
50
|
|
|
|
51
|
|
|
// process the functionality and return the row |
52
|
|
|
$this->process(); |
53
|
|
|
|
54
|
|
|
// return the processed row |
55
|
|
|
return $this->getRow(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Map's the passed attribute code to the attribute ID that has been created recently. |
60
|
|
|
* |
61
|
|
|
* @param string $attributeCode The attribute code that has to be mapped |
62
|
|
|
* |
63
|
|
|
* @return void |
64
|
|
|
*/ |
65
|
|
|
protected function addAttributeCodeIdMapping($attributeCode) |
66
|
|
|
{ |
67
|
|
|
$this->getSubject()->addAttributeCodeIdMapping($attributeCode); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Queries whether or not the attribute with the passed code has already been processed. |
72
|
|
|
* |
73
|
|
|
* @param string $attributeCode The attribute code to check |
74
|
|
|
* |
75
|
|
|
* @return boolean TRUE if the path has been processed, else FALSE |
76
|
|
|
*/ |
77
|
|
|
protected function hasBeenProcessed($attributeCode) |
78
|
|
|
{ |
79
|
|
|
return $this->getSubject()->hasBeenProcessed($attributeCode); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Process the observer's business logic. |
84
|
|
|
* |
85
|
|
|
* @return void |
86
|
|
|
*/ |
87
|
|
|
abstract protected function process(); |
88
|
|
|
} |
89
|
|
|
|