This commit is contained in:
2021-07-21 13:49:55 +08:00
parent 088745109f
commit d7302ceba5
7 changed files with 309 additions and 244 deletions
+10 -8
View File
@@ -24,7 +24,6 @@ use Database\Relation;
use Database\SqlBuilder;
use Database\Traits\HasBase;
use Exception;
use HttpServer\Http\Context;
use ReflectionException;
use Snowflake\Abstracts\Component;
use Snowflake\Abstracts\Config;
@@ -141,13 +140,21 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
}
/**
* @param Relation $relation
*/
public function setRelation(Relation $relation)
{
$this->_relation = $relation;
}
/**
* @throws Exception
*/
public function init()
{
$this->container = Snowflake::app();
$an = Snowflake::app()->getAnnotation();
$an->injectProperty($this);
}
@@ -1010,12 +1017,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
*/
public static function populate(array $data): static
{
// $class = Snowflake::app()->getChannel();
// /** @var static $model */
// $model = $class->pop(static::class, function () {
// return new static();
// });
$model = new static();
$model = duplicate(static::class);
$model->_attributes = $data;
$model->_oldAttributes = $data;
$model->setIsCreate(false);