X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FCommand%2FInstallCommand.php;h=42982e4a42240af3f9ed3647cc0866922131197c;hb=e57df5611fe82ce61a71d51c762ee9296f18c3ac;hp=8a2439ec7ebb6c3ec242dd3b29eb40c3b5614ba0;hpb=40d2a29443df8ef6fdf1f2d09b5ba8808543c245;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 8a2439ec..42982e4a 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -2,6 +2,8 @@ namespace Wallabag\CoreBundle\Command; +use FOS\UserBundle\Event\UserEvent; +use FOS\UserBundle\FOSUserEvents; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\ArrayInput; @@ -71,9 +73,11 @@ class InstallCommand extends ContainerAwareCommand { $this->defaultOutput->writeln('Step 1 of 4. Checking system requirements.'); - $fulfilled = true; + $rows = []; - $label = 'PDO Driver'; + // testing if database driver exists + $fulfilled = true; + $label = 'PDO Driver (%s)'; $status = 'OK!'; $help = ''; @@ -83,7 +87,23 @@ class InstallCommand extends ContainerAwareCommand $help = 'Database driver "'.$this->getContainer()->getParameter('database_driver').'" is not installed.'; } - $rows = []; + $rows[] = [sprintf($label, $this->getContainer()->getParameter('database_driver')), $status, $help]; + + // testing if connection to the database can be etablished + $label = 'Database connection'; + $status = 'OK!'; + $help = ''; + + try { + $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect(); + } catch (\Exception $e) { + if (false === strpos($e->getMessage(), 'Unknown database')) { + $fulfilled = false; + $status = 'ERROR!'; + $help = 'Can\'t connect to the database: '.$e->getMessage(); + } + } + $rows[] = [$label, $status, $help]; foreach ($this->functionExists as $functionRequired) { @@ -218,14 +238,9 @@ class InstallCommand extends ContainerAwareCommand $em->persist($user); - $config = new Config($user); - $config->setTheme($this->getContainer()->getParameter('wallabag_core.theme')); - $config->setItemsPerPage($this->getContainer()->getParameter('wallabag_core.items_on_page')); - $config->setRssLimit($this->getContainer()->getParameter('wallabag_core.rss_limit')); - $config->setReadingSpeed($this->getContainer()->getParameter('wallabag_core.reading_speed')); - $config->setLanguage($this->getContainer()->getParameter('wallabag_core.language')); - - $em->persist($config); + // dispatch a created event so the associated config will be created + $event = new UserEvent($user); + $this->getContainer()->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event); $this->defaultOutput->writeln(''); @@ -317,12 +332,12 @@ class InstallCommand extends ContainerAwareCommand 'section' => 'export', ], [ - 'name' => 'pocket_consumer_key', - 'value' => null, + 'name' => 'import_with_redis', + 'value' => '0', 'section' => 'import', ], [ - 'name' => 'rabbitmq', + 'name' => 'import_with_rabbitmq', 'value' => '0', 'section' => 'import', ], @@ -451,7 +466,7 @@ class InstallCommand extends ContainerAwareCommand } // custom verification for sqlite, since `getListDatabasesSQL` doesn't work for sqlite - if ('sqlite' == $schemaManager->getDatabasePlatform()->getName()) { + if ('sqlite' === $schemaManager->getDatabasePlatform()->getName()) { $params = $this->getContainer()->get('doctrine.dbal.default_connection')->getParams(); if (isset($params['path']) && file_exists($params['path'])) {