改名
This commit is contained in:
@@ -18,7 +18,6 @@ use Swoole\Coroutine;
|
|||||||
/**
|
/**
|
||||||
* Class BaseObject
|
* Class BaseObject
|
||||||
* @package Snowflake\Snowflake\Base
|
* @package Snowflake\Snowflake\Base
|
||||||
* @method afterInit
|
|
||||||
*/
|
*/
|
||||||
class BaseObject implements Configure
|
class BaseObject implements Configure
|
||||||
{
|
{
|
||||||
@@ -34,7 +33,6 @@ class BaseObject implements Configure
|
|||||||
if (!empty($config) && is_array($config)) {
|
if (!empty($config) && is_array($config)) {
|
||||||
Snowflake::configure($this, $config);
|
Snowflake::configure($this, $config);
|
||||||
}
|
}
|
||||||
$this->init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-17
@@ -11,7 +11,6 @@ namespace Snowflake\Di;
|
|||||||
|
|
||||||
use Annotation\Inject;
|
use Annotation\Inject;
|
||||||
use Exception;
|
use Exception;
|
||||||
use JetBrains\PhpStorm\Pure;
|
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use ReflectionFunction;
|
use ReflectionFunction;
|
||||||
@@ -109,22 +108,10 @@ class Container extends BaseObject
|
|||||||
{
|
{
|
||||||
$reflect = $this->resolveDependencies($class);
|
$reflect = $this->resolveDependencies($class);
|
||||||
|
|
||||||
$object = $this->setConfig($config, $reflect, $constrict);
|
$object = $this->newInstance($reflect, $constrict);
|
||||||
|
|
||||||
return $this->propertyInject($reflect, $object);
|
$this->propertyInject($reflect, $object);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $config
|
|
||||||
* @param $reflect
|
|
||||||
* @param $dependencies
|
|
||||||
* @return object
|
|
||||||
* @throws NotFindClassException
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
private function setConfig($config, $reflect, $dependencies): object
|
|
||||||
{
|
|
||||||
$object = $this->newInstance($reflect, $dependencies);
|
|
||||||
return $this->onAfterInit($object, $config);
|
return $this->onAfterInit($object, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,8 +200,8 @@ class Container extends BaseObject
|
|||||||
private function onAfterInit($object, $config): mixed
|
private function onAfterInit($object, $config): mixed
|
||||||
{
|
{
|
||||||
Snowflake::configure($object, $config);
|
Snowflake::configure($object, $config);
|
||||||
if (method_exists($object, 'afterInit')) {
|
if (method_exists($object, 'init')) {
|
||||||
call_user_func([$object, 'afterInit']);
|
call_user_func([$object, 'init']);
|
||||||
}
|
}
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user