|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverLeague\Console\Framework; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Application; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* The application scaffolder |
|
9
|
|
|
* |
|
10
|
|
|
* @package silverstripe-console |
|
11
|
|
|
* @author Robbie Averill <[email protected]> |
|
12
|
|
|
*/ |
|
13
|
|
|
class Scaffold extends ConsoleBase |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* The application name |
|
17
|
|
|
* @var string |
|
18
|
|
|
*/ |
|
19
|
|
|
const APPLICATION_NAME = <<<NAME |
|
20
|
|
|
_____ __ ______ _ _____ __ |
|
21
|
|
|
/ __(_) / _____ ____/ __/ /_____(_)__ ___ / ___/__ ___ ___ ___ / /__ |
|
22
|
|
|
_\ \/ / / |/ / -_) __/\ \/ __/ __/ / _ \/ -_) / /__/ _ \/ _ \(_-</ _ \/ / -_) |
|
23
|
|
|
/___/_/_/|___/\__/_/ /___/\__/_/ /_/ .__/\__/ \___/\___/_//_/___/\___/_/\__/ |
|
24
|
|
|
/_/ |
|
25
|
|
|
|
|
26
|
|
|
NAME; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* The application version (semver) |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
const APPLICATION_VERSION = '0.1.0'; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* The SilverStripe Loader class |
|
36
|
|
|
* @var SilverStripeLoader |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $loader; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Instantiate the console Application |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct() |
|
44
|
|
|
{ |
|
45
|
|
|
parent::__construct(new Application); |
|
46
|
|
|
$this->setLoader(new SilverStripeLoader($this->getApplication())); |
|
47
|
|
|
$this->scaffoldApplication(); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Run the console Application |
|
52
|
|
|
* |
|
53
|
|
|
* @see Application::run |
|
54
|
|
|
* @return int Error code, or zero if successful |
|
55
|
|
|
*/ |
|
56
|
|
|
public function run() |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->getApplication()->run(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Set the SilverStripeLoader |
|
63
|
|
|
* |
|
64
|
|
|
* @param SilverStripeLoader $loader |
|
65
|
|
|
* @return self |
|
66
|
|
|
*/ |
|
67
|
|
|
public function setLoader(SilverStripeLoader $loader) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->loader = $loader; |
|
70
|
|
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Get the SilverStripeLoader |
|
75
|
|
|
* |
|
76
|
|
|
* @return SilverStripeLoader |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getLoader() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->loader; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Scaffold the Application, including adding all requires commands and configuration |
|
85
|
|
|
* |
|
86
|
|
|
* @return self |
|
87
|
|
|
*/ |
|
88
|
|
|
protected function scaffoldApplication() |
|
89
|
|
|
{ |
|
90
|
|
|
$this->getApplication()->setName(self::APPLICATION_NAME); |
|
91
|
|
|
$this->getApplication()->setVersion('Version ' . self::APPLICATION_VERSION); |
|
92
|
|
|
|
|
93
|
|
|
foreach ($this->getLoader()->getTasks() as $command) { |
|
94
|
|
|
$this->getApplication()->add($command); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
$this->getApplication()->add(new \SilverLeague\Console\Command\Member\ChangeGroupsCommand); |
|
98
|
|
|
$this->getApplication()->add(new \SilverLeague\Console\Command\Member\ChangePasswordCommand); |
|
99
|
|
|
$this->getApplication()->add(new \SilverLeague\Console\Command\Member\CreateCommand); |
|
100
|
|
|
|
|
101
|
|
|
return $this; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|