Changeset View
Changeset View
Standalone View
Standalone View
core/kernel/utility/unit_config_reader.php
Show First 20 Lines • Show All 635 Lines • ▼ Show 20 Line(s) | |||||
if ( !isset($this->configData[$prefix]) ) { | if ( !isset($this->configData[$prefix]) ) { | ||||
$this->loadConfig($prefix); | $this->loadConfig($prefix); | ||||
} | } | ||||
return $this->configData[$prefix]; | return $this->configData[$prefix]; | ||||
} | } | ||||
/** | /** | ||||
* Returns prefixes of unit configs, that were registered | * Returns prefixes of unit configs, that were registered. | ||||
* | * | ||||
* @return Array | * @param boolean $loaded_only Only return prefixes, that were loaded till now. | ||||
* | |||||
* @return array | |||||
*/ | */ | ||||
public function getPrefixes() | public function getPrefixes($loaded_only = true) | ||||
{ | { | ||||
if ( $loaded_only ) { | |||||
return array_keys($this->configData); | return array_keys($this->configData); | ||||
} | } | ||||
return array_keys($this->prefixFiles); | |||||
} | |||||
/** | /** | ||||
* Get's config file name based | * Get's config file name based | ||||
* on folder name supplied | * on folder name supplied | ||||
* | * | ||||
* @param string $folder_path | * @param string $folder_path | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
protected function getConfigName($folder_path) | protected function getConfigName($folder_path) | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
/** | /** | ||||
* Returns unit config file location by it's prefix. | * Returns unit config file location by it's prefix. | ||||
* | * | ||||
* @param string $prefix Unit config prefix. | * @param string $prefix Unit config prefix. | ||||
* | * | ||||
* @return string | * @return string | ||||
* @throws Exception When unit config is not found. | * @throws InvalidArgumentException When unit config is not found. | ||||
*/ | */ | ||||
public function getPrefixFile($prefix) | public function getPrefixFile($prefix) | ||||
{ | { | ||||
if ( !isset($this->prefixFiles[$prefix]) ) { | if ( !isset($this->prefixFiles[$prefix]) ) { | ||||
throw new Exception('Configuration file for prefix "<strong>' . $prefix . '</strong>" is unknown'); | throw new InvalidArgumentException( | ||||
'Configuration file for prefix "<strong>' . $prefix . '</strong>" is unknown' | |||||
); | |||||
} | } | ||||
return $this->prefixFiles[$prefix]; | return $this->prefixFiles[$prefix]; | ||||
} | } | ||||
} | } |