コード例 #1
0
ファイル: ConfigUtilsTest.php プロジェクト: BGCX067/fajr-git
 public function testValidateFail()
 {
     $this->setExpectedException('\\Exception');
     $desc = array('a' => array('validator' => new ChoiceValidator(array('yes', 'no'))));
     $conf = array('a' => 'maybe');
     ConfigUtils::parseAndValidateConfiguration($desc, $conf);
 }
コード例 #2
0
ファイル: FajrConfig.php プロジェクト: BGCX067/fajr-git
 /**
  * Constructs FajrConfig
  *
  * @param array $configuration
  */
 public function __construct($configuration)
 {
     $parameters = self::getParameterDescription();
     $config = ConfigUtils::parseAndValidateConfiguration($parameters, $configuration);
     foreach ($config['AIS2.ServerList'] as $key => $server) {
         if ($key !== $server->getServerName()) {
             throw new Exception("Nesedí meno servera v konfiguracii AIS2.ServerList");
         }
     }
     $this->config = $config;
 }
コード例 #3
0
 public function __construct(array $options)
 {
     $this->config = ConfigUtils::parseAndValidateConfiguration($this->getParameterDescription(), $options);
 }
コード例 #4
0
 /**
  * Load configuration file, if it was not loaded previously.
  *
  * This means that second and subsequent calls attempt to load
  * the configuration again only if previous attempts have failed.
  *
  * Otherwise, cached configuration data is used.
  *
  * If the loading fails, isConfigured() will return false.
  *
  * @return void
  */
 public static function load()
 {
     if (self::isConfigured()) {
         return;
     }
     $parameters = self::getParameterDescription();
     $configurationFileName = self::getConfigurationFileName();
     if (!file_exists($configurationFileName)) {
         // Leave fajr unconfigured, index.php will then show nice error message
         // to the user
         return;
     }
     // Don't suppress errors so parse errors are reported
     // TODO(anty): use yaml for configuration
     $result = (include $configurationFileName);
     if (!is_array($result)) {
         throw new Exception('Konfiguračný súbor nevrátil pole');
     }
     $config = ConfigUtils::parseAndValidateConfiguration($parameters, $result);
     foreach ($config['AIS2.ServerList'] as $key => $server) {
         if ($key !== $server->getServerName()) {
             throw new Exception("Nesedí meno servera v konfiguracii AIS2.ServerList");
         }
     }
     self::$config = $config;
 }