profection the EventModel and EventService
This commit is contained in:
parent
3c393a9144
commit
f9dbc3e3db
|
@ -17,11 +17,15 @@ class HandleFactory extends AbstractServiceManager{
|
||||||
{
|
{
|
||||||
$config = $this->getServiceManager()->get('Config');
|
$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))
|
if(class_exists($handleName))
|
||||||
{
|
{
|
||||||
return new $handleName();
|
return new $handleName();
|
||||||
|
}else{
|
||||||
|
throw new \RuntimeException("Handle not exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,14 @@ class ListenerFactory extends AbstractServiceManager{
|
||||||
{
|
{
|
||||||
$config = $this->getServiceManager()->get('Config');
|
$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))
|
if(empty($handle))
|
||||||
return new $listenerName();
|
return new $listenerName();
|
||||||
|
|
|
@ -13,4 +13,5 @@ use Westdc\Member\Account as Westdc_Account;
|
||||||
class Account extends Westdc_Account{
|
class Account extends Westdc_Account{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,9 +15,9 @@ class Config {
|
||||||
|
|
||||||
public function get($configName = "")
|
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;
|
$config_path = CONFIG_PATH;
|
||||||
|
@ -25,19 +25,19 @@ class Config {
|
||||||
if(empty($configName))
|
if(empty($configName))
|
||||||
$configName = "global.php";
|
$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($config_path);
|
||||||
unset($configName);
|
unset($configName);
|
||||||
|
|
||||||
if(!file_exists($configFile))
|
if(!file_exists($configFile))
|
||||||
{
|
{
|
||||||
return NULL;
|
throw new \RuntimeException('The Config file is not exists');
|
||||||
}
|
}
|
||||||
|
|
||||||
$configFileExt = pathinfo($configFile,PATHINFO_EXTENSION);
|
$configFileExt = pathinfo($configFile,PATHINFO_EXTENSION);
|
||||||
|
@ -49,7 +49,9 @@ class Config {
|
||||||
|
|
||||||
if($configFileExt == 'ini')
|
if($configFileExt == 'ini')
|
||||||
{
|
{
|
||||||
return new ReaderIni($configFile);
|
$ini = new ReaderIni();
|
||||||
|
$ini->fromFile($configFile);
|
||||||
|
return $ini->fromFile($configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,18 +13,21 @@ use Westdc\EventModel\HandleFactory;
|
||||||
|
|
||||||
class Event {
|
class Event {
|
||||||
|
|
||||||
public function getListener($listenerName,$handleName = ""){
|
public function getListener($listenerName,$handle = ""){
|
||||||
$ListenerFactory = new ListenerFactory();
|
$ListenerFactory = new ListenerFactory();
|
||||||
if(empty($handleName))
|
if(empty($handle))
|
||||||
{
|
{
|
||||||
$ListenerFactory->get($listenerName);
|
return $ListenerFactory->get($listenerName);
|
||||||
}else{
|
}else{
|
||||||
$ListenerFactory->get($listenerName,$handleName);
|
return $ListenerFactory->get($listenerName,$handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHandle()
|
public function getHandle($handleName = "")
|
||||||
{
|
{
|
||||||
|
$handleFactory = new HandleFactory();
|
||||||
|
|
||||||
|
return $handleFactory->get($handleName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue