Пример #1
0
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $application = $input->getArgument('application');
     // TODO: this should be USER or optionally GROUP/USER or ALL when generating everything
     $directories = $input->getArgument('directories');
     $files = array();
     foreach ($directories as $dir) {
         $filelist = FileOperation::getAllFilesByExtension(Paths::$db . Paths::$separator . Paths::$defaultGroup . Paths::$separator . $dir, 'yml');
         if ($filelist !== false) {
             $files = array_merge($files, $filelist);
         } else {
             user_error('No such site: ' . $dir, E_USER_WARNING);
             //return false;
         }
     }
     //ApplicationsDB::LoadAll();
     $configScopes = ApplicationsDB::LoadApplication($application);
     $settingsDB = new ConfigScopes\SettingsDB();
     // merging the defaults
     $settingsDB->mergeFromYAML(Paths::$db . Paths::$separator . Paths::$hypoconf . Paths::$separator . Paths::$defaultUser . Paths::$separator . 'config.yml', false, true, true);
     //true for compilation
     // merging the files
     $settingsDB->mergeFromYAMLs($files, 'nginx/server', true, true, false, true);
     //true for compilation
     //var_dump($settingsDB->DB);
     ApplicationsDB::LoadConfig($settingsDB->DB);
     $parsedFile = $configScopes->parseTemplateRecursively($application);
     //        echo PHP_EOL.$parsedFile;
     $output->writeln($parsedFile);
 }
Пример #2
0
 public static function getFullPath($site)
 {
     $files = FileOperation::getAllFilesByExtension(Paths::$db, 'yml');
     $pathinfo = array();
     foreach ($files as $id => $file) {
         $pathinfo[$id] = FileOperation::pathinfo_utf($file);
         if ($pathinfo[$id]['filename'] == $site) {
             return $files[$id];
         }
     }
     return false;
 }
Пример #3
0
 /**
  * @static
  * @param string $application
  * @return object returns ConfigScopes instance
  */
 public static function LoadApplication($application)
 {
     // load templates:
     $templateFiles = FileOperation::getAllFilesByExtension(Paths::$apps . $application, 'tpl');
     self::$DB[$application]['templatesInstance'] = new TemplatesDB($templateFiles);
     self::$DB[$application]['templates'] = self::$DB[$application]['templatesInstance']->DB;
     // register possible settings:
     if (isset(self::$applications[$application])) {
         $classInfo = self::$applications[$application];
         $className = $classInfo[0];
     } else {
         // TODO: throw error
         return false;
     }
     self::$DB[$application]['parserInstance'] = new $className(self::$DB[$application]['templates']);
     self::$DB[$application]['parsers'] = self::$DB[$application]['parserInstance']->GetSubParsers();
     self::$DB[$application]['scopesInstance'] = new HypoConf\ConfigScopes(self::$DB[$application]['parsers'], self::$DB[$application]['templates']);
     self::$DB[$application]['scopesInstance']->rootscope = $application;
     return self::$DB[$application]['scopesInstance'];
 }
Пример #4
0
 public static function GenerateParsed($arguments)
 {
     $configScopesNginx = ApplicationsDB::LoadApplication('nginx');
     foreach ($arguments['file'] as $dir) {
         $fileslist = FileOperation::getAllFilesByExtension(Paths::$db . Paths::$separator . Paths::$defaultGroup . Paths::$separator . $dir, 'yml');
         if (!isset($fileslist) || $fileslist !== false) {
             foreach ($fileslist as $file) {
                 $files[] = $file;
             }
         } else {
             //            user_error('No such site: '.$arguments['file'], E_USER_ERROR);
             user_error('No such site: ' . $dir, E_USER_WARNING);
             return false;
         }
     }
     $nginx = new ConfigScopes\SettingsDB();
     $nginx->mergeFromYAML(Paths::$db . Paths::$separator . Paths::$hypoconf . Paths::$separator . Paths::$defaultUser . Paths::$separator . 'config.yml', false, true, true);
     //true for compilation
     $nginx->mergeFromYAMLs($files, 'server', true, true);
     //true for compilation
     ApplicationsDB::LoadConfig(&$nginx->DB);
     $parsedFile = $configScopesNginx->parseTemplateRecursively('nginx');
     echo PHP_EOL . $parsedFile;
 }