Ejemplo n.º 1
0
 /**
  * Read the config vars from ~/.cv.json.
  *
  * @return array
  */
 public function readHomeConfig()
 {
     if (!isset($this->cache['home'])) {
         $config = Config::read();
         $this->cache['home'] = isset($config['sites'][$this->settingsFile]) ? $config['sites'][$this->settingsFile] : array();
     }
     return $this->cache['home'];
 }
Ejemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->boot($input, $output);
     $config = Config::read();
     $oldSiteData = empty($config['sites'][CIVICRM_SETTINGS_PATH]) ? array() : $config['sites'][CIVICRM_SETTINGS_PATH];
     $oldJson = Encoder::encode($oldSiteData, 'json-pretty');
     $newJson = $this->editor->editBuffer($oldJson);
     $newSiteData = json_decode($newJson);
     print "NEW DATA\n\n====\n{$newJson}\n====\n";
     //    Config::update(function ($config) use ($newSiteData) {
     //      $config['sites'][CIVICRM_SETTINGS_PATH] = $newSiteData;
     //      return $config;
     //    });
 }
Ejemplo n.º 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!$input->getOption('file')) {
         $this->boot($input, $output);
         $reader = new SiteConfigReader(CIVICRM_SETTINGS_PATH);
         $liveData = $reader->compile(array('buildkit', 'home', 'active'));
     } else {
         $liveData = json_decode(file_get_contents($input->getOption('file')), 1);
     }
     if ($liveData === NULL) {
         throw new \RuntimeException("Failed to extract current configuration.");
     }
     $siteConfig = array();
     foreach ($this->defaults as $field => $value) {
         if (!isset($liveData[$field])) {
             $siteConfig[$field] = $value;
         }
     }
     $output->writeln(sprintf("<info>Site:</info> %s", CIVICRM_SETTINGS_PATH));
     if (empty($siteConfig)) {
         $output->writeln("<info>No extra fields are required.</info>");
     } else {
         $output->writeln(sprintf("<info>These fields were missing. Setting defaults:</info>"));
         $output->writeln(Encoder::encode($siteConfig, 'json-pretty'));
         Config::update(function ($config) use($siteConfig, $output) {
             if (isset($config['sites'][CIVICRM_SETTINGS_PATH])) {
                 $config['sites'][CIVICRM_SETTINGS_PATH] = array_merge($siteConfig, $config['sites'][CIVICRM_SETTINGS_PATH]);
             } else {
                 $config['sites'][CIVICRM_SETTINGS_PATH] = $siteConfig;
             }
             ksort($config['sites'][CIVICRM_SETTINGS_PATH]);
             return $config;
         });
         $output->writeln(sprintf("<info>Please edit</info> %s", Config::getFileName()));
     }
 }