Files
handbrake-cluster-webui/lib/RippingCluster/Config.class.php
Ben Roberts 89ddcba363 Renamed the codebase to RippingCluster
Since the new design is engine agnostic, removed HandBrake from the
class names.
2010-08-25 21:46:50 +01:00

57 lines
1.3 KiB
PHP

<?php
class RippingCluster_Config {
private $dbconfig;
private $database;
private $databaseConfig = array();
private $settings = array();
public function __construct($dbconfig) {
$this->dbconfig = $dbconfig;
$this->parseDatabaseConfig();
}
public function parseDatabaseConfig() {
$this->databaseConfig = parse_ini_file($this->dbconfig);
}
public function getDatabase($key) {
if (!isset($this->databaseConfig[$key])) {
throw new RippingCluster_Exception_DatabaseConfigMissing($key);
}
return $this->databaseConfig[$key];
}
public function setDatabase(RippingCluster_Database $database) {
$this->database = $database;
$this->preload();
}
public function preload() {
if (!$this->database) {
throw new RippingCluster_Exception_NoDatabaseConnection();
}
$this->settings = $this->database->selectAssoc('SELECT name,value FROM settings', 'name', 'value');
}
public function exists($key) {
return isset($this->settings[$key]);
}
public function get($key) {
if (!isset($this->settings[$key])) {
throw new RippingCluster_Exception_UnknownSetting($key);
}
return $this->settings[$key];
}
};
?>