Exemplo n.º 1
0
 /**
  * Execute the command.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @throws \Exception
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($this->isConfigured() && !$input->getOption('force')) {
         return $this->getOutput()->writeln('<error>AWS credentials detected, use --force to overwrite.</error>');
     }
     $writer = new IniWriter();
     if (!is_dir($this->getAwsDirPath())) {
         mkdir($this->getAwsDirPath());
     }
     if (!is_writeable($this->getAwsDirPath())) {
         return $this->getOutput()->writeln('<error>Unable to write AWS credentials.  Please manually add to ~/.aws/credentials</error>');
     }
     if (!is_dir($this->getAppDirPath())) {
         mkdir($this->getAppDirPath());
     }
     if (!is_writeable($this->getAppDirPath())) {
         return $this->getOutput()->writeln('<error>Unable to write Magedbm config.  Please manually add to ~/.magedbm/config</error>');
     }
     $credentials = array('default' => array('aws_access_key_id' => $input->getArgument('key'), 'aws_secret_access_key' => $input->getArgument('secret')));
     $config = array('default' => array('region' => $input->getArgument('region')));
     $magedbmconfig = array('default' => array('bucket' => $input->getArgument('bucket')));
     $writer->writeToFile($this->getAwsCredentialsPath(), $credentials);
     $writer->writeToFile($this->getAwsConfigPath(), $config);
     $writer->writeToFile($this->getAppConfigPath(), $magedbmconfig);
     $this->getOutput()->writeln('<info>Successfully configured.</info>');
 }
Exemplo n.º 2
0
 /**
  * Execute the command.
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @throws \Exception
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($this->isConfigured() && !$input->getOption('force')) {
         $this->getOutput()->writeln('<error>AWS credentials detected, use --force to overwrite.</error>');
         exit;
     }
     $writer = new IniWriter();
     if (!is_dir($this->getAwsDirPath())) {
         mkdir($this->getAwsDirPath());
     }
     if (!is_writeable($this->getAwsDirPath())) {
         $this->getOutput()->writeln('<error>Unable to write AWS credentials.  Please manually add to ~/.aws/credentials');
         exit;
     }
     if (!is_dir($this->getAppDirPath())) {
         mkdir($this->getAppDirPath());
     }
     if (!is_writeable($this->getAppDirPath())) {
         $this->getOutput()->writeln('<error>Unable to write Magedbm config.  Please manually add to ~/.magedbm/config');
         exit;
     }
     if ($input->getOption('key') && $input->getOption('secret')) {
         $credentials = array('default' => array('aws_access_key_id' => $input->getOption('key'), 'aws_secret_access_key' => $input->getOption('secret')));
         $writer->writeToFile($this->getAwsCredentialsPath(), $credentials);
         $this->getOutput()->writeln('<info>Successfully configured AWS credentials.</info>');
     } elseif (!file_exists($this->getAwsCredentialsPath())) {
         $this->getOutput()->writeln('<error>No AWS credentials were found, nor provided.</error>');
     }
     if ($input->getOption('region')) {
         $config = array('default' => array('region' => $input->getOption('region')));
         $writer->writeToFile($this->getAwsConfigPath(), $config);
         $this->getOutput()->writeln('<info>Successfully configured AWS region config.</info>');
     } else {
         if (!file_exists($this->getAwsConfigPath())) {
             $this->getOutput()->writeln('<error>No AWS config was found, nor provided.</error>');
         }
     }
     if ($input->getOption('bucket')) {
         $magedbmconfig = array('default' => array('bucket' => $input->getOption('bucket')));
         $writer->writeToFile($this->getAppConfigPath(), $magedbmconfig);
         $this->getOutput()->writeln('<info>Successfully configured magedbm config.</info>');
     } elseif (!file_exists($this->getAppConfigPath())) {
         $this->getOutput()->writeln('<error>No MageDBM was found, nor provided.</error>');
     }
 }
Exemplo n.º 3
0
 private function dumpSettings($values, $header)
 {
     $values = $this->encodeValues($values);
     $writer = new IniWriter();
     return $writer->writeToString($values, $header);
 }
 public function writeConfig()
 {
     $writer = new IniWriter();
     $writer->writeToFile($this->configFilename, $this->config);
 }