改名
This commit is contained in:
@@ -47,10 +47,10 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
|
||||
*
|
||||
* @param $query
|
||||
* @param array $array
|
||||
* @param null|string|ActiveRecord $model
|
||||
* @param string|ActiveRecord|null $model
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($query, array $array = [], $model = null)
|
||||
public function __construct($query, array $array = [], string|ActiveRecord $model = null)
|
||||
{
|
||||
$this->_item = $array;
|
||||
$this->query = $query;
|
||||
@@ -111,7 +111,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
|
||||
public function getModel(): ActiveRecord
|
||||
{
|
||||
if (!is_object($this->model)) {
|
||||
$this->model = $this->model::populate([]);
|
||||
$this->model = duplicate($this->model);
|
||||
$this->model->setIsCreate(false);
|
||||
}
|
||||
return $this->model;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -41,7 +41,7 @@ class CollectionIterator extends \ArrayIterator
|
||||
* @param int $flags
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($model, $query, $array = array(), $flags = 0)
|
||||
public function __construct($model, $query, array $array = [], int $flags = 0)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->query = $query;
|
||||
|
||||
Reference in New Issue
Block a user