From 5e11a4f03ea51d5503bbf324d733fe7f862b383d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sun, 25 Apr 2021 17:53:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Database/Base/BaseActiveRecord.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index bf9dcbe3..4a8322b7 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -126,6 +126,22 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess } + /** + * BaseActiveRecord constructor. + * @param array $config + * @throws Exception + */ + public function __construct($config = []) + { + $annotation = Snowflake::app()->getAnnotation(); + $this->_annotations[self::ANNOTATION_GET] = $annotation->getGets(static::class); + $this->_annotations[self::ANNOTATION_SET] = $annotation->getSets(static::class); + $this->_relate = $annotation->getRelateMethods(static::class); + + parent::__construct($config); + } + + /** * @throws NotFindClassException * @throws ReflectionException @@ -139,11 +155,6 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess } else { $this->_relation = Context::getContext(Relation::class); } - - $annotation = Snowflake::app()->getAnnotation(); - $this->_annotations[self::ANNOTATION_GET] = $annotation->getGets(static::class); - $this->_annotations[self::ANNOTATION_SET] = $annotation->getSets(static::class); - $this->_relate = $annotation->getRelateMethods(static::class); }