|
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
|
|
|
* Remove Command |
|
14
|
|
|
* |
|
15
|
|
|
* Removes Doctrine/Wildfire library from CodeIgniter. |
|
16
|
|
|
* |
|
17
|
|
|
* @package Combustor |
|
18
|
|
|
* @author Rougin Gutib <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class RemoveCommand 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
|
|
|
* Override this to check for x or y and return false if the command can not |
|
31
|
|
|
* run properly under the current conditions. |
|
32
|
|
|
* |
|
33
|
|
|
* @return bool |
|
34
|
|
|
*/ |
|
35
|
3 |
|
public function isEnabled() |
|
36
|
|
|
{ |
|
37
|
3 |
|
$file = APPPATH . 'libraries/' . $this->library . '.php'; |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
3 |
|
return file_exists($file); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Sets the configurations of the specified command. |
|
44
|
|
|
* |
|
45
|
|
|
* @return void |
|
46
|
|
|
*/ |
|
47
|
9 |
|
protected function configure() |
|
48
|
|
|
{ |
|
49
|
6 |
|
$this |
|
50
|
9 |
|
->setName('remove:' . $this->library) |
|
51
|
9 |
|
->setDescription('Removes ' . ucfirst($this->library)); |
|
52
|
9 |
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Executes the command. |
|
56
|
|
|
* |
|
57
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
|
58
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
|
59
|
|
|
* @return OutputInterface |
|
60
|
|
|
*/ |
|
61
|
6 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
62
|
|
|
{ |
|
63
|
6 |
|
$autoload = new Config('autoload', APPPATH . 'config'); |
|
|
|
|
|
|
64
|
|
|
|
|
65
|
6 |
|
$libraries = $autoload->get('libraries', 60, 'array'); |
|
66
|
|
|
|
|
67
|
6 |
|
if (in_array($this->library, $libraries)) { |
|
68
|
6 |
|
$position = array_search($this->library, $libraries); |
|
69
|
|
|
|
|
70
|
6 |
|
unset($libraries[$position]); |
|
71
|
|
|
|
|
72
|
6 |
|
$autoload->set('libraries', 60, $libraries, 'array'); |
|
73
|
6 |
|
$autoload->save(); |
|
74
|
4 |
|
} |
|
75
|
|
|
|
|
76
|
6 |
|
if ($this->library == 'doctrine') { |
|
77
|
3 |
|
system('composer remove doctrine/orm'); |
|
78
|
2 |
|
} |
|
79
|
|
|
|
|
80
|
6 |
|
unlink(APPPATH . 'libraries/' . ucfirst($this->library) . '.php'); |
|
81
|
|
|
|
|
82
|
6 |
|
$message = ucfirst($this->library) . ' is now successfully removed!'; |
|
83
|
|
|
|
|
84
|
6 |
|
return $output->writeln('<info>' . $message . '</info>'); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|