|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* @author Tom Klingenberg <[email protected]> |
|
4
|
|
|
* @copyright Copyright (c) 2016 netz98 new media GmbH (http://www.netz98.de) |
|
5
|
|
|
* |
|
6
|
|
|
* @see PROJECT_LICENSE.txt |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace N98\Magento\Api; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
use BadMethodCallException; |
|
13
|
|
|
use Magento\Framework\Module\ResourceInterface as ModuleResourceInterface; |
|
14
|
|
|
|
|
15
|
|
|
class ModuleVersion implements ModuleInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var Module |
|
19
|
|
|
*/ |
|
20
|
|
|
private $module; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var ModuleResource |
|
24
|
|
|
*/ |
|
25
|
|
|
private $resource; |
|
26
|
|
|
|
|
27
|
|
|
public function __construct(Module $module, ModuleResourceInterface $resource) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->module = $module; |
|
30
|
|
|
$this->resource = $resource; |
|
|
|
|
|
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritdoc} |
|
35
|
|
|
*/ |
|
36
|
|
|
public function getName() |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->module->getName(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritdoc} |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getVersion() |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->module->getVersion(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return string |
|
51
|
|
|
*/ |
|
52
|
|
View Code Duplication |
public function getDataVersion() |
|
|
|
|
|
|
53
|
|
|
{ |
|
54
|
|
|
$name = $this->getName(); |
|
55
|
|
|
$version = $this->resource->getDataVersion($name); |
|
56
|
|
|
if ($version === false) { |
|
57
|
|
|
throw new BadMethodCallException(sprintf("Module '%s' data-version is not available.", $name)); |
|
58
|
|
|
} |
|
59
|
|
|
return $version; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return string |
|
64
|
|
|
*/ |
|
65
|
|
View Code Duplication |
public function getDbVersion() |
|
|
|
|
|
|
66
|
|
|
{ |
|
67
|
|
|
$name = $this->getName(); |
|
68
|
|
|
$version = $this->resource->getDbVersion($name); |
|
69
|
|
|
if ($version === false) { |
|
70
|
|
|
throw new BadMethodCallException(sprintf("Module '%s' db-version is not available.", $name)); |
|
71
|
|
|
} |
|
72
|
|
|
return $version; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param string $version |
|
77
|
|
|
*/ |
|
78
|
|
|
public function setDataVersion($version) |
|
79
|
|
|
{ |
|
80
|
|
|
$this->resource->setDataVersion($this->getName(), $version); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param string $version |
|
85
|
|
|
*/ |
|
86
|
|
|
public function setDbVersion($version) |
|
87
|
|
|
{ |
|
88
|
|
|
$this->resource->setDbVersion($this->getName(), $version); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..