|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Product\Ee\Callbacks\RmaCallback |
|
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 2020 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-product-ee |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Ee\Callbacks; |
|
22
|
|
|
|
|
23
|
|
|
use TechDivision\Import\Product\Ee\Utils\ColumnKeys; |
|
24
|
|
|
use TechDivision\Import\Product\Ee\Utils\RmaKeysInterface; |
|
25
|
|
|
use TechDivision\Import\Product\Callbacks\AbstractProductImportCallback; |
|
26
|
|
|
use TechDivision\Import\Observers\AttributeCodeAndValueAwareObserverInterface; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* A callback implementation that converts the passed RMA key. |
|
30
|
|
|
* |
|
31
|
|
|
* @author Tim Wagner <[email protected]> |
|
32
|
|
|
* @copyright 2020 TechDivision GmbH <[email protected]> |
|
33
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
34
|
|
|
* @link https://github.com/techdivision/import-product-ee |
|
35
|
|
|
* @link http://www.techdivision.com |
|
36
|
|
|
*/ |
|
37
|
|
|
class RmaCallback extends AbstractProductImportCallback |
|
38
|
|
|
{ |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* The utility instance with the RMA keys. |
|
42
|
|
|
* |
|
43
|
|
|
* @var \TechDivision\Import\Product\Ee\Utils\RmaKeysInterface |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $rmaKeys; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Initializes the callback with the RMA keys instance. |
|
49
|
|
|
* |
|
50
|
|
|
* @param \TechDivision\Import\Product\Ee\Utils\RmaKeysInterface $rmaKeys The instance |
|
51
|
|
|
*/ |
|
52
|
|
|
public function __construct(RmaKeysInterface $rmaKeys) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->rmaKeys = $rmaKeys; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Will be invoked by a observer it has been registered for. |
|
59
|
|
|
* |
|
60
|
|
|
* @param \TechDivision\Import\Observers\AttributeCodeAndValueAwareObserverInterface|null $observer The observer |
|
61
|
|
|
* |
|
62
|
|
|
* @return int The converted value |
|
63
|
|
|
*/ |
|
64
|
|
|
public function handle(AttributeCodeAndValueAwareObserverInterface $observer = null) : int |
|
65
|
|
|
{ |
|
66
|
|
|
|
|
67
|
|
|
// set the observer |
|
68
|
|
|
$this->setObserver($observer); |
|
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
// replace the passed attribute value into the visibility ID |
|
71
|
|
|
return $this->getRmaKeys()->get($this->getValue(ColumnKeys::IS_RETURNABLE)); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Return's the instance with the RMA keys. |
|
76
|
|
|
* |
|
77
|
|
|
* @return \TechDivision\Import\Product\Ee\Utils\RmaKeysInterface The instance |
|
78
|
|
|
*/ |
|
79
|
|
|
protected function getRmaKeys() : RmaKeysInterface |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->rmaKeys; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):