Skip to content

Commit 4a2ecc0

Browse files
committed
Fixed merge conflict
2 parents 89a3369 + 2d730c6 commit 4a2ecc0

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed

Command/AcceptLicenseCommand.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
namespace Fuzzyma\Contao\DatabaseCommandsBundle\Command;
4+
5+
use Contao\CoreBundle\Command\AbstractLockedCommand;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Input\InputOption;
8+
use Symfony\Component\Console\Output\OutputInterface;
9+
use Symfony\Component\Console\Question\Question;
10+
11+
class AcceptLicenseCommand extends AbstractLockedCommand
12+
{
13+
14+
private $license = 'no';
15+
16+
protected function configure()
17+
{
18+
19+
$this
20+
->setName('contao:license')
21+
->setDescription('Accept the contao license');
22+
}
23+
24+
public function getQuestion($question, $default, $sep = ':')
25+
{
26+
return $default ? sprintf('<info>%s</info> [<comment>%s</comment>]%s ', $question, $default, $sep) : sprintf('<info>%s</info>%s ', $question, $sep);
27+
}
28+
29+
protected function interact(InputInterface $input, OutputInterface $output)
30+
{
31+
32+
$questionHelper = $this->getHelper('question');
33+
34+
$question = new Question($this->getQuestion('Do you want to accept the GNU GENERAL PUBLIC LICENSE', 'yes'), 'yes');
35+
$this->license = $questionHelper->ask($input, $output, $question);
36+
37+
}
38+
39+
protected function executeLocked(InputInterface $input, OutputInterface $output)
40+
{
41+
42+
$this->getContainer()->get('contao.framework')->initialize();
43+
44+
if($this->license == 'no'){
45+
$this->getContainer()->get('contao.install_tool')->persistConfig('licenseAccepted', false);
46+
$output->writeln('<error>Error: License was not accepted</error>');
47+
return;
48+
}
49+
50+
51+
$this->getContainer()->get('contao.install_tool')->persistConfig('licenseAccepted', true);
52+
53+
$output->writeln('<info>Success: License accepted</info>');
54+
55+
}
56+
57+
}

Command/SetupCommand.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace Fuzzyma\Contao\DatabaseCommandsBundle\Command;
4+
5+
use Contao\CoreBundle\Command\AbstractLockedCommand;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
use Symfony\Component\Console\Input\ArrayInput;
9+
10+
class SetupCommand extends AbstractLockedCommand
11+
{
12+
13+
protected function configure()
14+
{
15+
16+
$this
17+
->setName('contao:setup')
18+
->setDescription('Accepts license, updates database and creates admin user');
19+
}
20+
21+
protected function executeLocked(InputInterface $input, OutputInterface $output)
22+
{
23+
24+
$command = $this->getApplication()->find('contao:license');
25+
26+
if($command->run(new ArrayInput([]), $output)){
27+
return;
28+
}
29+
30+
$command = $this->getApplication()->find('contao:database:update');
31+
32+
if($command->run(new ArrayInput([]), $output)){
33+
return;
34+
}
35+
36+
$command = $this->getApplication()->find('contao:database:addAdmin');
37+
38+
if($command->run(new ArrayInput([]), $output)){
39+
return;
40+
}
41+
42+
}
43+
44+
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"type": "symfony-bundle",
55
"require": {
66
"contao/core-bundle": "^4.2",
7-
"symfony/console": "^2.8"
7+
"symfony/console": "^2.8",
8+
"contao/installation-bundle": "^1.1"
89
},
910
"autoload": {
1011
"psr-4": {

0 commit comments

Comments
 (0)