|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Zikula package. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright Zikula - https://ziku.la/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Zikula\Bundle\CoreInstallerBundle\Command; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\Console\Command\Command; |
|
17
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
19
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
|
20
|
|
|
use Symfony\Component\Filesystem\Exception\FileNotFoundException; |
|
21
|
|
|
use Zikula\Bundle\CoreInstallerBundle\Helper\PreCore3UpgradeHelper; |
|
22
|
|
|
|
|
23
|
|
|
class PreUpgradeCommand extends Command |
|
24
|
|
|
{ |
|
25
|
|
|
protected static $defaultName = 'zikula:pre-upgrade'; |
|
26
|
|
|
|
|
27
|
|
|
private $projectDir; |
|
28
|
|
|
|
|
29
|
|
|
public function __construct( |
|
30
|
|
|
string $projectDir, |
|
31
|
|
|
string $name = null |
|
32
|
|
|
) { |
|
33
|
|
|
parent::__construct($name); |
|
34
|
|
|
$this->projectDir = $projectDir; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
protected function configure() |
|
38
|
|
|
{ |
|
39
|
|
|
$this |
|
40
|
|
|
->setDescription('Setup the zikula upgrade command') |
|
41
|
|
|
; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
|
45
|
|
|
{ |
|
46
|
|
|
$io = new SymfonyStyle($input, $output); |
|
47
|
|
|
$helper = new PreCore3UpgradeHelper($this->projectDir); |
|
48
|
|
|
try { |
|
49
|
|
|
$result = $helper->preUpgrade(); |
|
50
|
|
|
} catch (FileNotFoundException $exception) { |
|
51
|
|
|
$io->error($exception->getMessage()); |
|
52
|
|
|
$io->text(sprintf('Copy your previous installation\'s %s to %s and run this command again.', '/app/config/custom_parameters.yml', $this->projectDir . '/config/services_custom.yaml')); |
|
53
|
|
|
|
|
54
|
|
|
return Command::FAILURE; |
|
55
|
|
|
} |
|
56
|
|
|
if ($result) { |
|
57
|
|
|
$io->success('Success! .env.local updated with Zikula Core 2.0.x settings. Please run php bin/console zikula:upgrade to continue the upgrade process.'); |
|
58
|
|
|
} else { |
|
59
|
|
|
$io->comment('There is no need to run this command unless the currently installed version is lower than 3.0.0'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
return Command::SUCCESS; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|