改名
This commit is contained in:
@@ -75,11 +75,24 @@ abstract class BaseApplication extends Component
|
|||||||
$this->parseEvents($config);
|
$this->parseEvents($config);
|
||||||
$this->initErrorHandler();
|
$this->initErrorHandler();
|
||||||
$this->enableEnvConfig();
|
$this->enableEnvConfig();
|
||||||
|
$this->mapping($config['mapping']);
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $mapping
|
||||||
|
*/
|
||||||
|
public function mapping(array $mapping)
|
||||||
|
{
|
||||||
|
$di = Kiri::getDi();
|
||||||
|
foreach ($mapping as $interface => $class) {
|
||||||
|
$di->mapping($interface, $class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -223,18 +236,18 @@ abstract class BaseApplication extends Component
|
|||||||
{
|
{
|
||||||
$eventProvider = di(EventProvider::class);
|
$eventProvider = di(EventProvider::class);
|
||||||
if ($value instanceof \Closure || is_object($value)) {
|
if ($value instanceof \Closure || is_object($value)) {
|
||||||
$eventProvider->on($key, $value,0);
|
$eventProvider->on($key, $value, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
if (is_object($value[0]) && !($value[0] instanceof \Closure)) {
|
if (is_object($value[0]) && !($value[0] instanceof \Closure)) {
|
||||||
$eventProvider->on($key, $value,0);
|
$eventProvider->on($key, $value, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($value[0])) {
|
if (is_string($value[0])) {
|
||||||
$value[0] = Kiri::createObject($value[0]);
|
$value[0] = Kiri::createObject($value[0]);
|
||||||
$eventProvider->on($key, $value,0);
|
$eventProvider->on($key, $value, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +255,7 @@ abstract class BaseApplication extends Component
|
|||||||
if (!is_callable($item, true)) {
|
if (!is_callable($item, true)) {
|
||||||
throw new InitException("Class does not hav callback.");
|
throw new InitException("Class does not hav callback.");
|
||||||
}
|
}
|
||||||
$eventProvider->on($key, $item,0);
|
$eventProvider->on($key, $item, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,16 @@ class Container extends BaseObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $interface
|
||||||
|
* @param $class
|
||||||
|
*/
|
||||||
|
public function mapping($interface, $class)
|
||||||
|
{
|
||||||
|
$this->_interfaces[$interface] = $class;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $class
|
* @param $class
|
||||||
* @return bool
|
* @return bool
|
||||||
|
|||||||
Reference in New Issue
Block a user