Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Wyjatek generowany w przypadku niemoznosci odnalezenia pliku konfiguracyjnego
- */
- class ConfigFileNotFoundException extends Exception
- {
- function __construct($message, $code = 0)
- {
- parent::__construct($message, $code);
- echo "<p><b>Config file not found</b></p>";
- }
- }
- // ...
- /**
- * Metoda realizuje pobranie konfiguracji projektu z pliku XML
- * @param string $cfg Nazwa pliku konfiguracyjnego (bez sciezki)
- */
- function load($cfg)
- {
- try
- {
- if (!file_exists($cfg))
- {
- throw new ConfigFileNotFoundException("Could not find {$cfg} file");
- }
- $config = $this->toArray(simplexml_load_file($cfg));
- }
- catch (ConfigFileNotFoundException $e)
- {
- echo $e->getMessage() . "<br />\n";
- echo "Should be on: {$cfg} \n";
- exit;
- }
- return $config;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement