1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
<?php
/**
* @author stev leibelt <artodeto@bazzline.net>
* @since 2014-08-17
*/
/**
* Class Command_Install
*/
class Command_Install extends Command_AbstractCommand
{
/**
* @var Configuration_Path
*/
private $pathConfiguration;
/**
* @var Filesystem
*/
private $filesystem;
/**
* @param Configuration_Path $configuration
*/
public function setPathConfiguration(Configuration_Path $configuration)
{
$this->pathConfiguration = $configuration;
}
/**
* @param Filesystem $filesystem
*/
public function setFilesystem(Filesystem $filesystem)
{
$this->filesystem = $filesystem;
}
/**
* @throws Exception
* @todo implement setup of database (check if connection is available, split it up in multiple steps (Command_Install_Files, Command_Install_Database)
*/
public function execute()
{
$identifierToPaths = array(
'channels' => array(
'example' => $this->pathConfiguration->getExampleChannelsFilePath(),
'chat' => $this->pathConfiguration->getChatChannelsFilePath()
),
'pathConfiguration' => array(
'example' => $this->pathConfiguration->getExampleConfigurationFilePath(),
'chat' => $this->pathConfiguration->getChatConfigurationFilePath()
),
'users' => array(
'example' => $this->pathConfiguration->getExampleUsersFilePath(),
'chat' => $this->pathConfiguration->getChatUsersFilePath()
),
'version' => array(
'example' => $this->pathConfiguration->getExampleVersionFilePath(),
'chat' => $this->pathConfiguration->getChatVersionFilePath()
),
);
foreach ($identifierToPaths as $identifier => $paths) {
if (!$this->filesystem->isFile($paths['chat'])) {
$directoryPath = dirname($paths['chat']);
if (!$this->filesystem->isDirectory($directoryPath)) {
$this->output->addLine('no directory available at "' . $directoryPath . '", will create one ...');
$this->filesystem->createDirectory($directoryPath);
}
$this->output->addLine('no ' . $identifier . ' file available, will create one ...');
$this->filesystem->copy(
$paths['example'],
$paths['chat']
);
} else {
$this->output->addLine($identifier . ' file available, nothing to do ...');
}
}
}
/**
* @return array
*/
public function getUsage()
{
return array();
}
/**
* @throws Exception
*/
public function verify()
{
}
}
|