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\Component; |
14
|
|
|
use ComponentManager\Moodle; |
15
|
|
|
use ComponentManager\PlatformUtil; |
16
|
|
|
use ComponentManager\Project\ComponentProjectFile; |
17
|
|
|
use ComponentManager\Project\Project; |
18
|
|
|
use ComponentManager\Project\ProjectFile; |
19
|
|
|
use ComponentManager\Project\ProjectLockFile; |
20
|
|
|
use Symfony\Component\Console\Command\Command; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Project-aware command trait. |
24
|
|
|
* |
25
|
|
|
* Provides helpful utility methods for accessing the project in the currrent |
26
|
|
|
* working directory. Import this into command implementations to reduce |
27
|
|
|
* duplication. |
28
|
|
|
*/ |
29
|
|
|
abstract class ComponentProjectAwareCommand extends Command { |
30
|
|
|
/** |
31
|
|
|
* Component project file. |
32
|
|
|
* |
33
|
|
|
* Lazily loaded -- be sure to call getProject() in order to ensure the |
34
|
|
|
* value is defined. |
35
|
|
|
* |
36
|
|
|
* @var \ComponentManager\Project\ComponentProjectFile |
37
|
|
|
*/ |
38
|
|
|
protected $componentProjectFile; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Get component project file. |
42
|
|
|
* |
43
|
|
|
* @return \ComponentManager\Project\ComponentProjectFile |
44
|
|
|
*/ |
45
|
|
|
protected function getComponentProjectFile() { |
46
|
|
|
if ($this->componentProjectFile === null) { |
47
|
|
|
$this->componentProjectFile = new ComponentProjectFile( |
48
|
|
|
ComponentProjectFile::FILENAME); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return $this->componentProjectFile; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|