protected function execute($arguments = array(), $options = array()) { $dbms = ''; $username = ''; $password = ''; $hostname = ''; $port = ''; $dbname = ''; $sock = ''; $maskedPassword = '******'; if ($options['redo']) { try { $this->configuration = parent::createConfiguration($options['application'], $options['env']); new sfDatabaseManager($this->configuration); } catch (Exception $e) { $this->logSection('installer', $e->getMessage(), null, 'ERROR'); $options['redo'] = false; } } if (!$options['redo']) { $validator = new sfValidatorCallback(array('required' => true, 'callback' => array($this, 'validateDBMS'))); $dbms = $this->askAndValidate(array('Choose DBMS:', '- mysql', '- pgsql (unsupported)', '- sqlite (unsupported)'), $validator, array('style' => 'QUESTION_LARGE')); if (!$dbms) { $this->logSection('installer', 'task aborted'); return 1; } if ($dbms !== 'sqlite') { $username = $this->askAndValidate(array('Type database username'), new opValidatorString(), array('style' => 'QUESTION_LARGE')); $password = $this->askAndValidate(array('Type database password (optional)'), new opValidatorString(array('required' => false)), array('style' => 'QUESTION_LARGE')); $hostname = $this->askAndValidate(array('Type database hostname'), new opValidatorString(), array('style' => 'QUESTION_LARGE')); $port = $this->askAndValidate(array('Type database port number (optional)'), new sfValidatorInteger(array('required' => false)), array('style' => 'QUESTION_LARGE')); } $dbname = $this->askAndValidate(array('Type database name'), new opValidatorString(), array('style' => 'QUESTION_LARGE')); if ($dbms == 'sqlite') { $dbname = realpath(dirname($dbname)) . DIRECTORY_SEPARATOR . basename($dbname); } if ($dbms == 'mysql' && ($hostname == 'localhost' || $hostname == '127.0.0.1')) { $sock = $this->askAndValidate(array('Type database socket path (optional)'), new opValidatorString(array('required' => false)), array('style' => 'QUESTION_LARGE')); } if (!$password) { $maskedPassword = ''; } $list = array('The DBMS : ' . $dbms, 'The Database Username : '******'The Database Password : '******'The Database Hostname : ' . $hostname, 'The Database Port Number : ' . $port, 'The Database Name : ' . $dbname, 'The Database Socket : ' . $sock); } $confirmAsk = 'Is it OK to start this task? (Y/n)'; $confirmAsks = isset($list) ? array_merge($list, array('', $confirmAsk)) : array($confirmAsk); if (!$this->askConfirmation($confirmAsks, 'QUESTION_LARGE')) { $this->logSection('installer', 'task aborted'); return 1; } $this->doInstall($dbms, $username, $password, $hostname, $port, $dbname, $sock, $options); if ($dbms === 'sqlite') { $this->getFilesystem()->chmod($dbname, 0666); } $this->publishAssets(); // _PEAR_call_destructors() causes an E_STRICT error error_reporting(error_reporting() & ~E_STRICT); $this->logSection('installer', 'installation is completed!'); }