改名
This commit is contained in:
+12
-13
@@ -42,21 +42,20 @@ class Service extends Component
|
|||||||
*/
|
*/
|
||||||
public function get($id, $try = true): mixed
|
public function get($id, $try = true): mixed
|
||||||
{
|
{
|
||||||
if (!isset($this->_components[$id])) {
|
if (isset($this->_components[$id])) {
|
||||||
if (!isset($this->_definition[$id])) {
|
return $this->_components[$id];
|
||||||
|
}
|
||||||
|
if (isset($this->_definition[$id])) {
|
||||||
|
$config = $this->_definition[$id];
|
||||||
|
if (!is_object($config)) {
|
||||||
|
$config = Snowflake::createObject($config);
|
||||||
|
}
|
||||||
|
return $this->_components[$id] = $config;
|
||||||
|
}
|
||||||
|
if ($try !== false) {
|
||||||
throw new ComponentException("Unknown component ID: $id");
|
throw new ComponentException("Unknown component ID: $id");
|
||||||
}
|
}
|
||||||
$config = $this->_definition[$id];
|
return null;
|
||||||
if (is_object($config)) {
|
|
||||||
return $config;
|
|
||||||
}
|
|
||||||
$this->_components[$id] = Snowflake::createObject($config);
|
|
||||||
}
|
|
||||||
$object = $this->_components[$id];
|
|
||||||
if (method_exists($object, 'afterInit')) {
|
|
||||||
$object->afterInit();
|
|
||||||
}
|
|
||||||
return $object;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user