eee
This commit is contained in:
+6
-3
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Kiri\Di;
|
namespace Kiri\Di;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri;
|
use Kiri;
|
||||||
|
|
||||||
@@ -23,14 +24,15 @@ class LocalService
|
|||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param $define
|
* @param $define
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function set($name, $define): void
|
public function set($name, $define): void
|
||||||
{
|
{
|
||||||
unset($this->_components[$name]);
|
unset($this->_components[$name]);
|
||||||
|
|
||||||
$this->_definition[$name] = $define;
|
$this->_definition[$name] = $define;
|
||||||
if (is_object($define) || $define instanceof \Closure) {
|
if (is_object($define) || $define instanceof Closure) {
|
||||||
$this->_components[$name] = $define;
|
$this->_components[$name] = $this->get($name, $define);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +47,7 @@ class LocalService
|
|||||||
}
|
}
|
||||||
if (isset($this->_definition[$name])) {
|
if (isset($this->_definition[$name])) {
|
||||||
$definition = $this->_definition[$name];
|
$definition = $this->_definition[$name];
|
||||||
if (is_object($definition) && !$definition instanceof \Closure) {
|
if (is_object($definition) && !$definition instanceof Closure) {
|
||||||
return $this->_components[$name] = $definition;
|
return $this->_components[$name] = $definition;
|
||||||
}
|
}
|
||||||
return $this->_components[$name] = Kiri::createObject($definition);
|
return $this->_components[$name] = Kiri::createObject($definition);
|
||||||
@@ -58,6 +60,7 @@ class LocalService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $components
|
* @param array $components
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function setComponents(array $components): void
|
public function setComponents(array $components): void
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user