diff --git a/src/EpiApi.php b/src/EpiApi.php index 45c45f2..a0a2654 100644 --- a/src/EpiApi.php +++ b/src/EpiApi.php @@ -64,6 +64,33 @@ public function invoke($route, $httpMethod = EpiRoute::httpGet, $params = array( return $retval; } + /** + * load('/path/to/file'); + * @name load + * @author Warrick Zedi + * @param string $file + */ + public function load($file) + { + $file = Epi::getPath('config') . "/{$file}"; + if(!file_exists($file)) + { + EpiException::raise(new EpiException("Config file ({$file}) does not exist")); + break; // need to simulate same behavior if exceptions are turned off + } + + $parsed_array = parse_ini_file($file, true); + foreach($parsed_array as $route) + { + $method = strtolower($route['method']); + $visibility = isset($route['visibility']) ? strtolower($route['visibility']) : self::internal; + if(isset($route['class']) && isset($route['function'])) + $this->$method($route['path'], array($route['class'], $route['function']), $visibility); + elseif(isset($route['function'])) + $this->$method($route['path'], $route['function'], $visibility); + } + } + /** * EpiApi::getRoute($route); * @name getRoute