|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Victor Dubiniuk <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Copyright (c) 2015, ownCloud, Inc. |
|
6
|
|
|
* @license AGPL-3.0 |
|
7
|
|
|
* |
|
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
10
|
|
|
* as published by the Free Software Foundation. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU Affero General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
19
|
|
|
* |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
namespace Owncloud\Updater\Command; |
|
23
|
|
|
|
|
24
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
25
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
26
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
27
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
28
|
|
|
|
|
29
|
|
|
class EnableNotShippedAppsCommand extends Command { |
|
30
|
|
|
|
|
31
|
|
|
protected function configure(){ |
|
32
|
|
|
$this |
|
33
|
|
|
->setName('upgrade:enableNotShippedApps') |
|
34
|
|
|
->setDescription('try reenable and upgrade 3rdparty/non shipped apps. (one app after another)') |
|
35
|
|
|
; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
protected function execute(InputInterface $input, OutputInterface $output){ |
|
39
|
|
|
/** @var \Owncloud\Updater\Utils\Locator $locator */ |
|
40
|
|
|
$locator = $this->container['utils.locator']; |
|
41
|
|
|
/** @var \Owncloud\Updater\Utils\Checkpoint $checkpoint */ |
|
42
|
|
|
$checkpoint = $this->container['utils.checkpoint']; |
|
43
|
|
|
/** @var \Owncloud\Updater\Utils\FilesystemHelper $fsHelper */ |
|
44
|
|
|
$fsHelper = $this->container['utils.filesystemhelper']; |
|
45
|
|
|
|
|
46
|
|
|
$registry = $this->container['utils.registry']; |
|
47
|
|
|
|
|
48
|
|
|
$notShippedApps = $registry->get('notShippedApps'); |
|
49
|
|
|
$notShippedApps = is_array($notShippedApps) ? $notShippedApps : []; |
|
50
|
|
|
|
|
51
|
|
|
$lastCheckpointId = $checkpoint->getLastCheckpointId(); |
|
52
|
|
|
$lastCheckpointPath = $checkpoint->getCheckpointPath($lastCheckpointId); |
|
|
|
|
|
|
53
|
|
|
if ($lastCheckpointId){ |
|
54
|
|
|
$oldSourcesDir = $locator->getOwnCloudRootPath(); |
|
55
|
|
|
foreach ($notShippedApps as $notShippedApp) { |
|
56
|
|
|
$fsHelper->copyr($lastCheckpointPath . '/apps/' . $notShippedApp, $oldSourcesDir . '/apps/' . $notShippedApp, false); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** @var \Owncloud\Updater\Utils\AppManager $appManager */ |
|
61
|
|
|
$appManager = $registry->get('appManager'); |
|
62
|
|
|
if (!is_null($appManager)){ |
|
63
|
|
|
$appManager->reenableNotShippedApps($output); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.