]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Command/InstallCommand.php
add test for removeWww Twig Extension
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Command / InstallCommand.php
index ac7583ea7f7d74770a9fca4761dd6ba207fa9f71..1bd76ae36ec9db535b68ce33926d09228a886eec 100644 (file)
@@ -192,12 +192,14 @@ class InstallCommand extends ContainerAwareCommand
         $user->setUsername($dialog->ask($this->defaultOutput, '<question>Username</question> <comment>(default: wallabag)</comment> :', 'wallabag'));
         $user->setPassword($dialog->ask($this->defaultOutput, '<question>Password</question> <comment>(default: wallabag)</comment> :', 'wallabag'));
         $user->setEmail($dialog->ask($this->defaultOutput, '<question>Email:</question>', ''));
+        $user->setEnabled(true);
 
         $em->persist($user);
 
         $config = new Config($user);
         $config->setTheme($this->getContainer()->getParameter('theme'));
         $config->setItemsPerPage($this->getContainer()->getParameter('items_on_page'));
+        $config->setRssLimit($this->getContainer()->getParameter('rss_limit'));
         $config->setLanguage($this->getContainer()->getParameter('language'));
 
         $em->persist($config);
@@ -224,7 +226,7 @@ class InstallCommand extends ContainerAwareCommand
     }
 
     /**
-     * Run a command
+     * Run a command.
      *
      * @param string $command
      * @param array  $parameters Parameters to this command (usually 'force' => true)
@@ -265,16 +267,17 @@ class InstallCommand extends ContainerAwareCommand
     }
 
     /**
-     * Check if the database already exists
+     * Check if the database already exists.
      *
-     * @return boolean
+     * @return bool
      */
     private function isDatabasePresent()
     {
-        $databaseName = $this->getContainer()->getParameter('database_name');
+        $connection = $this->getContainer()->get('doctrine')->getManager()->getConnection();
+        $databaseName = $connection->getDatabase();
 
         try {
-            $schemaManager = $this->getContainer()->get('doctrine')->getManager()->getConnection()->getSchemaManager();
+            $schemaManager = $connection->getSchemaManager();
         } catch (\Exception $exception) {
             if (false !== strpos($exception->getMessage(), sprintf("Unknown database '%s'", $databaseName))) {
                 return false;
@@ -298,14 +301,15 @@ class InstallCommand extends ContainerAwareCommand
     }
 
     /**
-     * Check if the schema is already created
+     * Check if the schema is already created.
+     * If we found at least oen table, it means the schema exists.
      *
-     * @return boolean
+     * @return bool
      */
     private function isSchemaPresent()
     {
         $schemaManager = $this->getContainer()->get('doctrine')->getManager()->getConnection()->getSchemaManager();
 
-        return $schemaManager->tablesExist(array('entry'));
+        return count($schemaManager->listTableNames()) > 0 ? true : false;
     }
 }