コード例 #1
0
ファイル: ShowCommand.php プロジェクト: civicrm/cv
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->boot($input, $output);
     $reader = new SiteConfigReader(CIVICRM_SETTINGS_PATH);
     $data = $reader->compile(array('buildkit', 'home', 'active'));
     $this->sendResult($input, $output, $data);
 }
コード例 #2
0
ファイル: FillCommand.php プロジェクト: civicrm/cv
 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()));
     }
 }