Example #1
0
 function loadFromCiviDSN($civi_dsn)
 {
     $parsed_dsn = \DB\DSN::parseDSN($civi_dsn);
     foreach (static::$cividsn_to_settings_name as $key => $value) {
         if (array_key_exists($key, $parsed_dsn)) {
             $this->{$value} = $parsed_dsn[$key];
         }
     }
     $this->updateHost();
 }
Example #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $instance = $this->instances->find(Instance::makeId($input->getOption('root'), $input->getOption('name')));
     if (!$instance) {
         throw new \Exception("Failed to locate instance: " . Instance::makeId($input->getOption('root'), $input->getOption('name')));
     }
     $prefix = $input->getOption('prefix');
     $dsnParts = \DB\DSN::parseDSN($instance->getDsn());
     $output_file_path = $input->getOption('output-file');
     if ($output_file_path != '') {
         $output_file = fopen($output_file_path, "w");
         $output = new StreamOutput($output_file);
     }
     $envVars = array("{$prefix}URL" => $instance->getUrl(), "{$prefix}ROOT" => $instance->getRoot(), "{$prefix}DB_DSN" => $instance->getDsn(), "{$prefix}DB_USER" => $dsnParts['username'], "{$prefix}DB_PASS" => $dsnParts['password'], "{$prefix}DB_HOST" => $dsnParts['hostspec'], "{$prefix}DB_PORT" => $dsnParts['port'], "{$prefix}DB_NAME" => $dsnParts['database'], "{$prefix}DB_ARGS" => $instance->getDatasource() ? $instance->getDatasource()->toMySQLArguments() : '');
     foreach ($envVars as $var => $value) {
         $output->writeln($var . '=' . escapeshellarg($value));
     }
     // $output->writeln('export ' . implode(' ', array_keys($envVars)));
 }