改名
This commit is contained in:
@@ -69,6 +69,7 @@ abstract class BaseApplication extends Service
|
|||||||
|
|
||||||
$this->moreComponents();
|
$this->moreComponents();
|
||||||
$this->parseInt($config);
|
$this->parseInt($config);
|
||||||
|
$this->parseEvents($config);
|
||||||
$this->initErrorHandler();
|
$this->initErrorHandler();
|
||||||
$this->enableEnvConfig();
|
$this->enableEnvConfig();
|
||||||
|
|
||||||
@@ -164,6 +165,31 @@ abstract class BaseApplication extends Service
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $config
|
||||||
|
*
|
||||||
|
* @throws
|
||||||
|
*/
|
||||||
|
public function parseEvents($config)
|
||||||
|
{
|
||||||
|
if (!isset($config['events']) || !is_array($config['events'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$event = Snowflake::app()->event;
|
||||||
|
foreach ($config['events'] as $key => $value) {
|
||||||
|
if (is_string($value)) {
|
||||||
|
if (!class_exists($value)) {
|
||||||
|
throw new InitException("Class {$value} does not exists.");
|
||||||
|
}
|
||||||
|
$value = Snowflake::createObject($value);
|
||||||
|
} else if (is_array($value) && !is_callable($value, true)) {
|
||||||
|
throw new InitException("Class does not hav callback.");
|
||||||
|
}
|
||||||
|
$event->on($key, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
|||||||
Reference in New Issue
Block a user