modify
This commit is contained in:
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user