|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Klaus Herberth <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* @license AGPL-3.0 |
|
8
|
|
|
* |
|
9
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
11
|
|
|
* as published by the Free Software Foundation. |
|
12
|
|
|
* |
|
13
|
|
|
* This program is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU Affero General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace OC\Core\Command\App; |
|
24
|
|
|
|
|
25
|
|
|
use OC\Installer; |
|
26
|
|
|
use Symfony\Component\Console\Command\Command; |
|
27
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
28
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
29
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
30
|
|
|
|
|
31
|
|
|
class Install extends Command { |
|
32
|
|
|
|
|
33
|
|
|
protected function configure() { |
|
34
|
|
|
$this |
|
35
|
|
|
->setName('app:install') |
|
36
|
|
|
->setDescription('install an app') |
|
37
|
|
|
->addArgument( |
|
38
|
|
|
'app-id', |
|
39
|
|
|
InputArgument::REQUIRED, |
|
40
|
|
|
'install the specified app' |
|
41
|
|
|
) |
|
42
|
|
|
; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) { |
|
46
|
|
|
$appId = $input->getArgument('app-id'); |
|
47
|
|
|
|
|
48
|
|
|
if (\OC_App::getAppPath($appId)) { |
|
|
|
|
|
|
49
|
|
|
$output->writeln($appId . ' already installed'); |
|
50
|
|
|
return 1; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
try { |
|
54
|
|
|
$installer = new Installer( |
|
55
|
|
|
\OC::$server->getAppFetcher(), |
|
56
|
|
|
\OC::$server->getHTTPClientService(), |
|
57
|
|
|
\OC::$server->getTempManager(), |
|
58
|
|
|
\OC::$server->getLogger(), |
|
59
|
|
|
\OC::$server->getConfig() |
|
60
|
|
|
); |
|
61
|
|
|
$installer->downloadApp($appId); |
|
62
|
|
|
$result = $installer->installApp($appId); |
|
63
|
|
|
} catch(\Exception $e) { |
|
64
|
|
|
$output->writeln('Error: ' . $e->getMessage()); |
|
65
|
|
|
return 1; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
if($result === false) { |
|
69
|
|
|
$output->writeln($appId . ' couldn\'t be installed'); |
|
70
|
|
|
return 1; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
$output->writeln($appId . ' installed'); |
|
74
|
|
|
|
|
75
|
|
|
return 0; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: