X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FCommand%2FInstallCommand.php;h=3873d2d366762b88241874bb27415696b0b1cca3;hb=55345331c47ca6f389e38a842584c3062476601d;hp=2e4a59dfdb92910d32e7d360eb837b493cc41584;hpb=15e94833230b57779154059d29e5faf5b459e883;p=github%2Fwallabag%2Fwallabag.git
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 2e4a59df..3873d2d3 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -60,7 +60,7 @@ class InstallCommand extends ContainerAwareCommand
->checkRequirements()
->setupDatabase()
->setupAdmin()
- ->setupAsset()
+ ->setupConfig()
;
$output->writeln('Wallabag has been successfully installed.');
@@ -71,8 +71,10 @@ class InstallCommand extends ContainerAwareCommand
{
$this->defaultOutput->writeln('Step 1 of 4. Checking system requirements.');
- $fulfilled = true;
+ $rows = [];
+ // testing if database driver exists
+ $fulfilled = true;
$label = 'PDO Driver';
$status = 'OK!';
$help = '';
@@ -83,7 +85,23 @@ class InstallCommand extends ContainerAwareCommand
$help = 'Database driver "'.$this->getContainer()->getParameter('database_driver').'" is not installed.';
}
- $rows = [];
+ $rows[] = [$label, $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) {
@@ -227,10 +245,25 @@ class InstallCommand extends ContainerAwareCommand
$em->persist($config);
+ $this->defaultOutput->writeln('');
+
+ return $this;
+ }
+
+ protected function setupConfig()
+ {
+ $this->defaultOutput->writeln('Step 4 of 4. Config setup.');
+ $em = $this->getContainer()->get('doctrine.orm.entity_manager');
+
// cleanup before insert new stuff
$em->createQuery('DELETE FROM CraueConfigBundle:Setting')->execute();
$settings = [
+ [
+ 'name' => 'share_public',
+ 'value' => '1',
+ 'section' => 'entry',
+ ],
[
'name' => 'carrot',
'value' => '1',
@@ -302,8 +335,13 @@ class InstallCommand extends ContainerAwareCommand
'section' => 'export',
],
[
- 'name' => 'pocket_consumer_key',
- 'value' => null,
+ 'name' => 'import_with_redis',
+ 'value' => '0',
+ 'section' => 'import',
+ ],
+ [
+ 'name' => 'import_with_rabbitmq',
+ 'value' => '0',
'section' => 'import',
],
[
@@ -363,20 +401,6 @@ class InstallCommand extends ContainerAwareCommand
return $this;
}
- protected function setupAsset()
- {
- $this->defaultOutput->writeln('Step 4 of 4. Installing assets.');
-
- $this
- ->runCommand('assets:install')
- ->runCommand('assetic:dump')
- ;
-
- $this->defaultOutput->writeln('');
-
- return $this;
- }
-
/**
* Run a command.
*
@@ -445,7 +469,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'])) {
@@ -457,7 +481,7 @@ class InstallCommand extends ContainerAwareCommand
try {
return in_array($databaseName, $schemaManager->listDatabases());
- } catch (\Doctrine\DBAL\Exception\ConnectionException $e) {
+ } catch (\Doctrine\DBAL\Exception\DriverException $e) {
// it means we weren't able to get database list, assume the database doesn't exist
return false;