|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Moodle component manager. |
|
5
|
|
|
* |
|
6
|
|
|
* @author Luke Carrier <[email protected]> |
|
7
|
|
|
* @copyright 2016 Luke Carrier |
|
8
|
|
|
* @license GPL-3.0+ |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace ComponentManager\Command; |
|
12
|
|
|
|
|
13
|
|
|
use ComponentManager\Platform\Platform; |
|
14
|
|
|
use ComponentManager\Project\ComponentProjectFile; |
|
15
|
|
|
use Symfony\Component\Console\Command\Command; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Project-aware command trait. |
|
19
|
|
|
* |
|
20
|
|
|
* Provides helpful utility methods for accessing the project in the currrent |
|
21
|
|
|
* working directory. Import this into command implementations to reduce |
|
22
|
|
|
* duplication. |
|
23
|
|
|
*/ |
|
24
|
|
|
abstract class ComponentProjectAwareCommand extends Command { |
|
25
|
|
|
/** |
|
26
|
|
|
* Component project file. |
|
27
|
|
|
* |
|
28
|
|
|
* Lazily loaded -- be sure to call getProject() in order to ensure the |
|
29
|
|
|
* value is defined. |
|
30
|
|
|
* |
|
31
|
|
|
* @var \ComponentManager\Project\ComponentProjectFile |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $componentProjectFile; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Platform support library. |
|
37
|
|
|
* |
|
38
|
|
|
* @var \ComponentManager\Platform\Platform |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $platform; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Initialiser. |
|
44
|
|
|
* |
|
45
|
|
|
* @param \ComponentManager\Platform\Platform $platform |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct(Platform $platform) { |
|
48
|
|
|
$this->platform = $platform; |
|
49
|
|
|
|
|
50
|
|
|
parent::__construct(); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Get component project file. |
|
55
|
|
|
* |
|
56
|
|
|
* @return \ComponentManager\Project\ComponentProjectFile |
|
57
|
|
|
*/ |
|
58
|
|
|
protected function getComponentProjectFile() { |
|
59
|
|
|
if ($this->componentProjectFile === null) { |
|
60
|
|
|
$this->componentProjectFile = new ComponentProjectFile( |
|
61
|
|
|
ComponentProjectFile::FILENAME); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
return $this->componentProjectFile; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|