|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2018-2020 |
|
6
|
|
|
* @package Controller |
|
7
|
|
|
* @subpackage Common |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Common\Supplier\Import\Csv\Processor; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Abstract class with common methods for all CSV import processors |
|
16
|
|
|
* |
|
17
|
|
|
* @package Controller |
|
18
|
|
|
* @subpackage Common |
|
19
|
|
|
*/ |
|
20
|
|
|
class Base |
|
21
|
|
|
extends \Aimeos\Controller\Common\Supplier\Import\Csv\Base |
|
22
|
|
|
{ |
|
23
|
|
|
private $context; |
|
24
|
|
|
private $mapping; |
|
25
|
|
|
private $object; |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Initializes the object |
|
30
|
|
|
* |
|
31
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Context object |
|
32
|
|
|
* @param array $mapping Associative list of field position in CSV as key and domain item key as value |
|
33
|
|
|
* @param \Aimeos\Controller\Common\Supplier\Import\Csv\Processor\Iface $object Decorated processor |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping, |
|
36
|
|
|
\Aimeos\Controller\Common\Supplier\Import\Csv\Processor\Iface $object = null ) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->context = $context; |
|
39
|
|
|
$this->mapping = $mapping; |
|
40
|
|
|
$this->object = $object; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Returns the context item |
|
46
|
|
|
* |
|
47
|
|
|
* @return \Aimeos\MShop\Context\Item\Iface Context object |
|
48
|
|
|
*/ |
|
49
|
|
|
protected function getContext() : \Aimeos\MShop\Context\Item\Iface |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->context; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Returns the mapping list |
|
57
|
|
|
* |
|
58
|
|
|
* @return array Associative list of field positions in CSV as keys and domain item keys as values |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function getMapping() : array |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->mapping; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Returns the decorated processor object |
|
68
|
|
|
* |
|
69
|
|
|
* @return \Aimeos\Controller\Common\Supplier\Import\Csv\Processor\Iface Processor object |
|
70
|
|
|
* @throws \Aimeos\Controller\Jobs\Exception If no processor object is available |
|
71
|
|
|
*/ |
|
72
|
|
|
protected function getObject() : Iface |
|
73
|
|
|
{ |
|
74
|
|
|
if( $this->object === null ) { |
|
75
|
|
|
throw new \Aimeos\Controller\Jobs\Exception( 'No processor object available' ); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
return $this->object; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|