This commit is contained in:
2021-07-13 16:35:57 +08:00
parent 71503fbdcc
commit 52bc8eef02
+5
View File
@@ -28,6 +28,7 @@ use ReflectionException;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
use Snowflake\Abstracts\Config; use Snowflake\Abstracts\Config;
use Snowflake\Abstracts\TraitApplication; use Snowflake\Abstracts\TraitApplication;
use Snowflake\Application;
use Snowflake\Exception\ConfigException; use Snowflake\Exception\ConfigException;
use Snowflake\Exception\NotFindClassException; use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
@@ -73,6 +74,9 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
private array $_annotations = []; private array $_annotations = [];
protected ?Application $container;
/** /**
* @var bool * @var bool
*/ */
@@ -125,6 +129,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
*/ */
public function init() public function init()
{ {
$this->container = Snowflake::app();
if (!Context::hasContext(Relation::class)) { if (!Context::hasContext(Relation::class)) {
$relation = Snowflake::createObject(Relation::class); $relation = Snowflake::createObject(Relation::class);
$this->_relation = Context::setContext(Relation::class, $relation); $this->_relation = Context::setContext(Relation::class, $relation);