|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Loaders\RegistryLoader |
|
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 2019 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 |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Loaders; |
|
22
|
|
|
|
|
23
|
|
|
use TechDivision\Import\Utils\RegistryKeys; |
|
24
|
|
|
use TechDivision\Import\Services\RegistryProcessorInterface; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Generic loader for data from the registry. |
|
28
|
|
|
* |
|
29
|
|
|
* @author Tim Wagner <[email protected]> |
|
30
|
|
|
* @copyright 2019 TechDivision GmbH <[email protected]> |
|
31
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
32
|
|
|
* @link https://github.com/techdivision/import |
|
33
|
|
|
* @link http://www.techdivision.com |
|
34
|
|
|
*/ |
|
35
|
|
|
class RegistryLoader implements LoaderInterface |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* The registry processor instance. |
|
40
|
|
|
* |
|
41
|
|
|
* @var \TechDivision\Import\Services\RegistryProcessorInterface |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $registryProcessor; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Registry key to load the data with. |
|
47
|
|
|
* |
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $registryKey; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Construct that initializes the iterator with the registry processor instance. |
|
54
|
|
|
* |
|
55
|
|
|
* @param \TechDivision\Import\Services\RegistryProcessorInterface $registryProcessor The registry processor instance |
|
56
|
|
|
* @param string $registryKey The registry key to load the data with |
|
57
|
|
|
*/ |
|
58
|
|
|
public function __construct(RegistryProcessorInterface $registryProcessor, $registryKey = RegistryKeys::STATUS) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->registryProcessor = $registryProcessor; |
|
61
|
|
|
$this->registryKey = $registryKey; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Loads and returns data. |
|
66
|
|
|
* |
|
67
|
|
|
* @return \ArrayAccess The array with the data |
|
68
|
|
|
*/ |
|
69
|
|
|
public function load() |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->getRegistryProcessor()->load($this->getRegistryKey()); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Return's the registry key to load the data with. |
|
76
|
|
|
* |
|
77
|
|
|
* @return string The registry key |
|
78
|
|
|
*/ |
|
79
|
|
|
protected function getRegistryKey() |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->registryKey; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Return's the registry processor instance. |
|
86
|
|
|
* |
|
87
|
|
|
* @return \TechDivision\Import\Services\RegistryProcessorInterface The processor instance |
|
88
|
|
|
*/ |
|
89
|
|
|
protected function getRegistryProcessor() |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->registryProcessor; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|