aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Command/InstallCommand.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-11-06 23:39:19 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2015-11-06 23:39:19 +0100
commit78507d28357b132237ad35ecdf0704d1ca56dfaa (patch)
treee9e54c0636fede716dc62f44b93848c91949aaed /src/Wallabag/CoreBundle/Command/InstallCommand.php
parent872384b0c18a4c39d7d996e600b25a8568fa6963 (diff)
downloadwallabag-78507d28357b132237ad35ecdf0704d1ca56dfaa.tar.gz
wallabag-78507d28357b132237ad35ecdf0704d1ca56dfaa.tar.zst
wallabag-78507d28357b132237ad35ecdf0704d1ca56dfaa.zip
Fix deprecated helper in command
Diffstat (limited to 'src/Wallabag/CoreBundle/Command/InstallCommand.php')
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 6ebbd93c..808baaf6 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -8,6 +8,9 @@ use Symfony\Component\Console\Input\InputOption;
8use Symfony\Component\Console\Input\ArrayInput; 8use Symfony\Component\Console\Input\ArrayInput;
9use Symfony\Component\Console\Output\OutputInterface; 9use Symfony\Component\Console\Output\OutputInterface;
10use Symfony\Component\Console\Output\NullOutput; 10use Symfony\Component\Console\Output\NullOutput;
11use Symfony\Component\Console\Question\Question;
12use Symfony\Component\Console\Question\ConfirmationQuestion;
13use Symfony\Component\Console\Helper\Table;
11use Wallabag\UserBundle\Entity\User; 14use Wallabag\UserBundle\Entity\User;
12use Wallabag\CoreBundle\Entity\Config; 15use Wallabag\CoreBundle\Entity\Config;
13 16
@@ -85,10 +88,11 @@ class InstallCommand extends ContainerAwareCommand
85 } 88 }
86 $rows[] = array($label, $status, $help); 89 $rows[] = array($label, $status, $help);
87 90
88 $this->getHelper('table') 91 $table = new Table($this->defaultOutput);
92 $table
89 ->setHeaders(array('Checked', 'Status', 'Recommendation')) 93 ->setHeaders(array('Checked', 'Status', 'Recommendation'))
90 ->setRows($rows) 94 ->setRows($rows)
91 ->render($this->defaultOutput); 95 ->render();
92 96
93 if (!$fulfilled) { 97 if (!$fulfilled) {
94 throw new \RuntimeException('Some system requirements are not fulfilled. Please check output messages and fix them.'); 98 throw new \RuntimeException('Some system requirements are not fulfilled. Please check output messages and fix them.');
@@ -130,9 +134,10 @@ class InstallCommand extends ContainerAwareCommand
130 return $this; 134 return $this;
131 } 135 }
132 136
133 $dialog = $this->getHelper('dialog'); 137 $questionHelper = $this->getHelper('question');
138 $question = new ConfirmationQuestion('It appears that your database already exists. Would you like to reset it? (y/N)', false);
134 139
135 if ($dialog->askConfirmation($this->defaultOutput, '<question>It appears that your database already exists. Would you like to reset it? (y/N)</question> ', false)) { 140 if ($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) {
136 $this->defaultOutput->writeln('Droping database, creating database and schema'); 141 $this->defaultOutput->writeln('Droping database, creating database and schema');
137 142
138 $this 143 $this
@@ -141,7 +146,8 @@ class InstallCommand extends ContainerAwareCommand
141 ->runCommand('doctrine:schema:create') 146 ->runCommand('doctrine:schema:create')
142 ; 147 ;
143 } elseif ($this->isSchemaPresent()) { 148 } elseif ($this->isSchemaPresent()) {
144 if ($dialog->askConfirmation($this->defaultOutput, '<question>Seems like your database contains schema. Do you want to reset it? (y/N)</question> ', false)) { 149 $question = new ConfirmationQuestion('Seems like your database contains schema. Do you want to reset it? (y/N)', false);
150 if ($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) {
145 $this->defaultOutput->writeln('Droping schema and creating schema'); 151 $this->defaultOutput->writeln('Droping schema and creating schema');
146 152
147 $this 153 $this
@@ -160,17 +166,6 @@ class InstallCommand extends ContainerAwareCommand
160 $this->defaultOutput->writeln('Clearing the cache'); 166 $this->defaultOutput->writeln('Clearing the cache');
161 $this->runCommand('cache:clear'); 167 $this->runCommand('cache:clear');
162 168
163 /*
164 if ($this->getHelperSet()->get('dialog')->askConfirmation($this->defaultOutput, '<question>Load fixtures (Y/N)?</question>', false)) {
165 $doctrineConfig = $this->getContainer()->get('doctrine.orm.entity_manager')->getConnection()->getConfiguration();
166 $logger = $doctrineConfig->getSQLLogger();
167 // speed up fixture load
168 $doctrineConfig->setSQLLogger(null);
169 $this->runCommand('doctrine:fixtures:load');
170 $doctrineConfig->setSQLLogger($logger);
171 }
172 */
173
174 $this->defaultOutput->writeln(''); 169 $this->defaultOutput->writeln('');
175 170
176 return $this; 171 return $this;
@@ -180,9 +175,10 @@ class InstallCommand extends ContainerAwareCommand
180 { 175 {
181 $this->defaultOutput->writeln('<info><comment>Step 3 of 4.</comment> Administration setup.</info>'); 176 $this->defaultOutput->writeln('<info><comment>Step 3 of 4.</comment> Administration setup.</info>');
182 177
183 $dialog = $this->getHelperSet()->get('dialog'); 178 $questionHelper = $this->getHelperSet()->get('question');
179 $question = new ConfirmationQuestion('Would you like to create a new user ? (y/N)', false);
184 180
185 if (false === $dialog->askConfirmation($this->defaultOutput, '<question>Would you like to create a new user ? (y/N)</question>', true)) { 181 if (!$questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) {
186 return $this; 182 return $this;
187 } 183 }
188 184
@@ -190,9 +186,16 @@ class InstallCommand extends ContainerAwareCommand
190 186
191 $userManager = $this->getContainer()->get('fos_user.user_manager'); 187 $userManager = $this->getContainer()->get('fos_user.user_manager');
192 $user = $userManager->createUser(); 188 $user = $userManager->createUser();
193 $user->setUsername($dialog->ask($this->defaultOutput, '<question>Username</question> <comment>(default: wallabag)</comment> :', 'wallabag')); 189
194 $user->setPlainPassword($dialog->ask($this->defaultOutput, '<question>Password</question> <comment>(default: wallabag)</comment> :', 'wallabag')); 190 $question = new Question('Username (default: wallabag) :', 'wallabag');
195 $user->setEmail($dialog->ask($this->defaultOutput, '<question>Email:</question>', '')); 191 $user->setUsername($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question));
192
193 $question = new Question('Password (default: wallabag) :', 'wallabag');
194 $user->setPlainPassword($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question));
195
196 $question = new Question('Email:', '');
197 $user->setEmail($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question));
198
196 $user->setEnabled(true); 199 $user->setEnabled(true);
197 200
198 $em->persist($user); 201 $em->persist($user);