From 8b57f44f7e9bf05daf877bd4d5293c034dd57d25 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Fri, 23 Apr 2021 03:07:29 +0800 Subject: [PATCH] modify --- Database/ActiveRecord.php | 15 ---------- Database/Base/AbstractCollection.php | 7 +---- Database/Base/BaseActiveRecord.php | 8 +---- Database/Base/CollectionIterator.php | 7 +---- Database/InjectProperty.php | 45 ---------------------------- 5 files changed, 3 insertions(+), 79 deletions(-) delete mode 100644 Database/InjectProperty.php diff --git a/Database/ActiveRecord.php b/Database/ActiveRecord.php index 06b4dce0..a6399525 100644 --- a/Database/ActiveRecord.php +++ b/Database/ActiveRecord.php @@ -310,24 +310,9 @@ class ActiveRecord extends BaseActiveRecord $data[$key] = $this->runAnnotation($key, $data[$key] ?? null); } $data = array_merge($data, $this->runRelate()); - $this->recover(); return $data; } - - /** - * @throws Exception - */ - public function recover() - { - $this->clean(); - - /** @var Channel $channel */ - $channel = Snowflake::app()->get('channel'); - $channel->push($this, get_called_class()); - } - - /** * @return array * @throws Exception diff --git a/Database/Base/AbstractCollection.php b/Database/Base/AbstractCollection.php index fa7dc3ed..ec9fd1ac 100644 --- a/Database/Base/AbstractCollection.php +++ b/Database/Base/AbstractCollection.php @@ -120,12 +120,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat if (is_object($model)) { return $model; } - - /** @var Channel $channel */ - $channel = Snowflake::app()->get('channel'); - return $channel->pop($model, function () use ($model) { - return new $model(); - }); + return new $model(); } diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index 24e121c9..147b3f2e 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -1029,13 +1029,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess */ public static function populate(array $data): static { - $className = get_called_class(); - - /** @var Channel $channel */ - $channel = Snowflake::app()->get('channel'); - $model = $channel->pop($className, function () use ($className) { - return new $className(); - }); + $model = new static(); $model->_attributes = $data; $model->setIsCreate(false); $model->refresh(); diff --git a/Database/Base/CollectionIterator.php b/Database/Base/CollectionIterator.php index d62b3869..bf4ef5a1 100644 --- a/Database/Base/CollectionIterator.php +++ b/Database/Base/CollectionIterator.php @@ -62,12 +62,7 @@ class CollectionIterator extends \ArrayIterator if (is_object($model)) { $model = get_class($model); } - - /** @var Channel $channel */ - $channel = Snowflake::app()->get('channel'); - $model = $channel->pop($model, function () use ($model) { - return new $model(); - }); + $model = new $model(); return $model->setAttributes($current); } diff --git a/Database/InjectProperty.php b/Database/InjectProperty.php deleted file mode 100644 index ee06e631..00000000 --- a/Database/InjectProperty.php +++ /dev/null @@ -1,45 +0,0 @@ -handler, func_get_args()); - - $this->handler[0]->createAnnotation(); - - echo 'inject property.' . PHP_EOL; - - return $data; - } - -}