This commit is contained in:
2021-04-26 13:57:13 +08:00
parent d1e3a3017b
commit 76f9688ea6
3 changed files with 8 additions and 5 deletions
+4
View File
@@ -312,6 +312,10 @@ class ActiveRecord extends BaseActiveRecord
$data[$key] = $this->{$item}($data[$key] ?? null); $data[$key] = $this->{$item}($data[$key] ?? null);
} }
$data = array_merge($data, $this->runRelate()); $data = array_merge($data, $this->runRelate());
$class = Snowflake::app()->getChannel();
$class->push($this, static::class);
return $data; return $data;
} }
+4 -1
View File
@@ -1060,8 +1060,11 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
*/ */
public static function populate(array $data): static public static function populate(array $data): static
{ {
$class = Snowflake::app()->getChannel();
/** @var static $model */ /** @var static $model */
$model = Snowflake::createObject(static::class); $model = $class->pop(static::class, function () {
return new static();
});
$model->_attributes = $data; $model->_attributes = $data;
$model->_oldAttributes = $data; $model->_oldAttributes = $data;
$model->setIsCreate(false); $model->setIsCreate(false);
-4
View File
@@ -28,8 +28,6 @@ class Channel extends Component
*/ */
public function push(mixed $value, string $name = ''): void public function push(mixed $value, string $name = ''): void
{ {
unset($value);
return;
$channel = $this->channelInit($name); $channel = $this->channelInit($name);
$channel->enqueue($value); $channel->enqueue($value);
} }
@@ -75,8 +73,6 @@ class Channel extends Component
*/ */
public function pop(string $name, Closure $closure, int|float $timeout = null): mixed public function pop(string $name, Closure $closure, int|float $timeout = null): mixed
{ {
return call_user_func($closure);
if (($channel = $this->channelInit($name)) == false) { if (($channel = $this->channelInit($name)) == false) {
return $this->addError('Channel is full.'); return $this->addError('Channel is full.');
} }