diff --git a/Westdc/EventModel/HandleFactory.php b/Westdc/EventModel/HandleFactory.php index 529fda1..aa008e7 100644 --- a/Westdc/EventModel/HandleFactory.php +++ b/Westdc/EventModel/HandleFactory.php @@ -17,11 +17,15 @@ class HandleFactory extends AbstractServiceManager{ { $config = $this->getServiceManager()->get('Config'); - $handleName = $config->get('application.ini')->HandlesNamespace . "\\" . $handleName; + $appConfig = $config->get('application.ini'); + + $handleName = $appConfig['HandlesNamespace'] . "\\" . $handleName; if(class_exists($handleName)) { return new $handleName(); + }else{ + throw new \RuntimeException("Handle not exists"); } } diff --git a/Westdc/EventModel/ListenerFactory.php b/Westdc/EventModel/ListenerFactory.php index 31a35dc..18b4d7a 100644 --- a/Westdc/EventModel/ListenerFactory.php +++ b/Westdc/EventModel/ListenerFactory.php @@ -17,7 +17,14 @@ class ListenerFactory extends AbstractServiceManager{ { $config = $this->getServiceManager()->get('Config'); - $listenerName = $config->get('application.ini')->ListenersNamespace . "\\" . $listenerName; + $appConfig = $config->get('application.ini'); + + $listenerName =$appConfig['ListenersNamespace'] . "\\" . $listenerName; + + if(!class_exists($listenerName)) + { + throw new \RuntimeException("Listener [" . $listenerName . "] not found"); + } if(empty($handle)) return new $listenerName(); diff --git a/Westdc/Service/ServiceAgent/Account.php b/Westdc/Service/ServiceAgent/Account.php index 15834ce..b35cee4 100644 --- a/Westdc/Service/ServiceAgent/Account.php +++ b/Westdc/Service/ServiceAgent/Account.php @@ -13,4 +13,5 @@ use Westdc\Member\Account as Westdc_Account; class Account extends Westdc_Account{ + } \ No newline at end of file diff --git a/Westdc/Service/ServiceAgent/Config.php b/Westdc/Service/ServiceAgent/Config.php index c0d90c0..57a2341 100644 --- a/Westdc/Service/ServiceAgent/Config.php +++ b/Westdc/Service/ServiceAgent/Config.php @@ -15,9 +15,9 @@ class Config { public function get($configName = "") { - if(!defined(CONFIG_PATH)) + if(defined(CONFIG_PATH)) { - throw new RuntimeException('Not found the config files path'); + throw new \RuntimeException('Not found the config files path'); } $config_path = CONFIG_PATH; @@ -25,19 +25,19 @@ class Config { if(empty($configName)) $configName = "global.php"; - if(!preg_match("/(\\/|\\)$/",$config_path)) + if(!preg_match("/(\\/|\\\)$/",$config_path)) { - $config_path .= PATH_SEPARATOR; + $config_path .= "/"; } - $configFile = $config_path . $configName; + $configFile = $config_path .'autoload/' . $configName; unset($config_path); unset($configName); if(!file_exists($configFile)) { - return NULL; + throw new \RuntimeException('The Config file is not exists'); } $configFileExt = pathinfo($configFile,PATHINFO_EXTENSION); @@ -49,7 +49,9 @@ class Config { if($configFileExt == 'ini') { - return new ReaderIni($configFile); + $ini = new ReaderIni(); + $ini->fromFile($configFile); + return $ini->fromFile($configFile); } } diff --git a/Westdc/Service/ServiceAgent/Event.php b/Westdc/Service/ServiceAgent/Event.php index b0bdf16..799f0ad 100644 --- a/Westdc/Service/ServiceAgent/Event.php +++ b/Westdc/Service/ServiceAgent/Event.php @@ -13,18 +13,21 @@ use Westdc\EventModel\HandleFactory; class Event { - public function getListener($listenerName,$handleName = ""){ + public function getListener($listenerName,$handle = ""){ $ListenerFactory = new ListenerFactory(); - if(empty($handleName)) + if(empty($handle)) { - $ListenerFactory->get($listenerName); + return $ListenerFactory->get($listenerName); }else{ - $ListenerFactory->get($listenerName,$handleName); + return $ListenerFactory->get($listenerName,$handle); } } - public function getHandle() + public function getHandle($handleName = "") { + $handleFactory = new HandleFactory(); + + return $handleFactory->get($handleName); }