|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Rougin\Combustor\Common\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
6
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
7
|
|
|
|
|
8
|
|
|
use Rougin\Combustor\Common\Tools; |
|
9
|
|
|
use Rougin\Combustor\Common\Config; |
|
10
|
|
|
use Rougin\Combustor\Commands\AbstractCommand; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Install Command |
|
14
|
|
|
* |
|
15
|
|
|
* Installs Doctrine/Wildfire library for CodeIgniter. |
|
16
|
|
|
* |
|
17
|
|
|
* @package Combustor |
|
18
|
|
|
* @author Rougin Gutib <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class InstallCommand extends AbstractCommand |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $library = ''; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Checks whether the command is enabled or not in the current environment. |
|
29
|
|
|
* |
|
30
|
|
|
* @return boolean |
|
31
|
|
|
*/ |
|
32
|
3 |
|
public function isEnabled() |
|
33
|
|
|
{ |
|
34
|
3 |
|
$library = ($this->library == 'doctrine') ? 'Wildfire' : 'Doctrine'; |
|
35
|
|
|
|
|
36
|
3 |
|
return ! file_exists(APPPATH . 'libraries/' . $library . '.php'); |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Sets the configurations of the specified command. |
|
41
|
|
|
* |
|
42
|
|
|
* @return void |
|
43
|
|
|
*/ |
|
44
|
33 |
|
protected function configure() |
|
45
|
|
|
{ |
|
46
|
22 |
|
$this |
|
47
|
33 |
|
->setName('install:' . $this->library) |
|
48
|
33 |
|
->setDescription('Installs ' . ucfirst($this->library)); |
|
49
|
33 |
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Adds the specified library in the autoload.php. |
|
53
|
|
|
* |
|
54
|
|
|
* @param string $library |
|
55
|
|
|
* @return void |
|
56
|
|
|
*/ |
|
57
|
30 |
|
protected function addLibrary($library) |
|
58
|
|
|
{ |
|
59
|
30 |
|
$autoload = new Config('autoload', APPPATH . 'config'); |
|
|
|
|
|
|
60
|
|
|
|
|
61
|
30 |
|
$libraries = $autoload->get('libraries', 60, 'array'); |
|
62
|
|
|
|
|
63
|
30 |
|
if (! in_array($library, $libraries)) { |
|
64
|
30 |
|
array_push($libraries, $library); |
|
65
|
|
|
|
|
66
|
30 |
|
$autoload->set('libraries', 60, $libraries, 'array'); |
|
67
|
30 |
|
$autoload->save(); |
|
68
|
20 |
|
} |
|
69
|
30 |
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|