Skip to content

Commit

Permalink
改进初始化方法
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Feb 11, 2025
1 parent 00af62f commit cdeab3d
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,6 @@ protected function initializeData(array | object $data, bool $fromSave = false)
}

$trueName = $this->getRealFieldName($name);
if (!$this->isView() && !$fromSave && $this->getPk() == $trueName) {
// 记录主键值
$this->model()->setKey($val);
}

if ($this->isView() || $this->isVirtual() || in_array($trueName, $fields)) {
// 读取数据后进行类型转换
$value = $this->readTransform($val, $schema[$trueName] ?? 'string');
Expand All @@ -382,6 +377,7 @@ protected function initializeData(array | object $data, bool $fromSave = false)
if (!empty($origin) && !$fromSave) {
$this->trigger('AfterRead');
$this->setOption('origin', $origin);
$this->setOption('get', []);
}
}

Expand Down Expand Up @@ -1225,7 +1221,6 @@ protected function setData(string $name, $value)
public function data(array $data)
{
$this->initializeData($data);
$this->setOption('get', []);
}

/**
Expand Down

0 comments on commit cdeab3d

Please sign in to comment.