This commit is contained in:
as2252258@163.com
2021-02-23 03:02:34 +08:00
parent 3388ba7e0f
commit 74460526a4
2 changed files with 112 additions and 110 deletions
+3 -3
View File
@@ -63,9 +63,9 @@ class Container extends BaseObject
*/
public function get($class, $constrict = [], $config = []): mixed
{
// if (isset($this->_singletons[$class])) {
// return $this->_singletons[$class];
// }
if (isset($this->_singletons[$class])) {
return $this->_singletons[$class];
}
if (!isset($this->_constructs[$class])) {
return $this->resolve($class, $constrict, $config);
}
+13 -11
View File
@@ -43,19 +43,21 @@ class Service extends Component
if (isset($this->_components[$id])) {
return $this->_components[$id];
}
if (isset($this->_definition[$id])) {
$object = $this->_definition[$id];
if (!is_object($object)) {
$object = Snowflake::createObject($object);
}
} else if (!isset($this->_alias[$id])) {
if (!isset($this->_definition[$id]) && !isset($this->_alias[$id])) {
throw new ComponentException("Unknown component ID: $id");
} else {
$id = $this->_alias[$id];
$object = Snowflake::createObject($id);
}
return $this->_components[$id] = $object;
if (isset($this->_definition[$id])) {
$config = $this->_definition[$id];
if (is_object($config)) {
return $this->_components[$id] = $config;
}
$object = Snowflake::createObject($config);
} else {
$config = $this->_alias[$id];
$object = Snowflake::createObject($config);
}
return $this->_components[$id] = Snowflake::configure($object, $config);
}
/**