/**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $install = new sfSympalInstall($this->configuration, $this->dispatcher, $this->formatter);
     $install->setApplication($arguments['application']);
     $msg = array();
     $msg[] = 'This command will remove all data in your configured databases and initialize the sympal database.';
     $msg[] = 'Are you sure you want to proceed? (y/N)';
     $type = 'ERROR_LARGE';
     if (!$options['no-confirmation'] && !$this->askConfirmation($msg, $type, false)) {
         $this->logSection('sympal', 'Install task aborted');
         return 1;
     }
     // setup some arguments
     $install->setParam('email_address', $options['email']);
     $install->setParam('username', $options['username']);
     $install->setParam('password', $options['password']);
     if (isset($options['first-name'])) {
         $install->setParam('first_name', $options['first-name']);
     }
     if (isset($options['last-name'])) {
         $install->setParam('last_name', $options['last-name']);
     }
     // Set the install to not excess log if trace is off
     if (!$this->commandApplication->withTrace()) {
         $install->setTrace(false);
     }
     // run the install
     $cmdFormatted = $this->formatter->format('sympal:install -t', 'COMMENT');
     $this->logSection('sympal', sprintf('Installation starting. Run "%s" to see debug output', $cmdFormatted));
     $this->log(null);
     $install->install();
     // display a nice message
     $this->log(null);
     $this->logSection('sympal', sprintf('sympal was installed successfully...', $arguments['application']), null, 'COMMENT');
     $url = 'http://localhost/' . $arguments['application'] . '_dev.php/security/signin';
     $this->logSection('sympal', sprintf('Open your browser to "%s"', $url), null, 'COMMENT');
     $this->logSection('sympal', sprintf('You can signin with the username "%s" and password "%s"', $install->getParam('username'), $install->getParam('password')), null, 'COMMENT');
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $install = new sfSympalInstall($this->configuration, $this->dispatcher, $this->formatter);
     $install->setApplication($arguments['application']);
     $msg = array();
     if (isset($options['force-reinstall']) && $options['force-reinstall']) {
         $msg[] = 'This command will remove all data in your configured databases and initialize the Sympal database.';
         $type = 'ERROR_LARGE';
     } else {
         if ($install->checkSympalSiteExists()) {
             $msg[] = sprintf('Sympal has already been installed for the application named "%s".', $arguments['application']);
             $msg[] = 'Do you wish to delete the site and re-create it?';
             $msg[] = '';
             $msg[] = 'Use the --force-reinstall option to reinstall Sympal completely.';
             $msg[] = '';
             $type = 'ERROR_LARGE';
         } else {
             if ($install->checkSympalDatabaseExists() && !$install->checkSympalSiteExists()) {
                 $msg[] = sprintf('Sympal has already been installed but the application named "%s" has not had a site created for it yet.', $arguments['application']);
                 $msg[] = 'Do you want to create a site record for this application?';
                 $msg[] = '';
                 $msg[] = 'Use the --force-reinstall option to reinstall Sympal completely.';
                 $msg[] = '';
                 $type = 'QUESTION_LARGE';
             } else {
                 $msg[] = sprintf('This command will initialize the sympal Database for the application named "%s".', $arguments['application']);
                 $type = 'QUESTION_LARGE';
             }
         }
     }
     $msg[] = 'Are you sure you want to proceed? (y/N)';
     if (!$options['no-confirmation'] && !$this->askConfirmation($msg, $type, false)) {
         $this->logSection('sympal', 'Install task aborted');
         return 1;
     }
     $install->setParam('email_address', $options['email-address']);
     $install->setParam('username', $options['username']);
     $install->setParam('password', $options['password']);
     if (isset($options['first-name'])) {
         $install->setParam('first_name', $options['first-name']);
     }
     if (isset($options['last-name'])) {
         $install->setParam('last_name', $options['last-name']);
     }
     if (isset($options['db-dsn'])) {
         $install->setParam('db_dsn', $options['db-dsn']);
     }
     if (isset($options['db-username'])) {
         $install->setParam('db_username', $options['db-username']);
     }
     if (isset($options['db-password'])) {
         $install->setParam('db_password', $options['db-password']);
     }
     if (isset($options['force-reinstall']) && $options['force-reinstall']) {
         $install->setOption('force_reinstall', true);
     }
     $install->setOption('build_classes', (bool) $options['build-classes']);
     $install->install();
     $this->log(null);
     $this->logSection('sympal', sprintf('Sympal was installed successfully...', $arguments['application']), null, 'COMMENT');
     $url = 'http://localhost/' . $arguments['application'] . '_dev.php/security/signin';
     $this->logSection('sympal', sprintf('Open your browser to "%s"', $url), null, 'COMMENT');
     $this->logSection('sympal', sprintf('You can signin with the username "%s" and password "%s"', $install->getParam('username'), $install->getParam('password')), null, 'COMMENT');
 }