public function populate($rows)
{
if (empty($rows)) {
return [];
}
$models = $this->createModels($rows);
if (!empty($this->join) && $this->indexBy === null) {
$models = $this->removeDuplicatedModels($models);
}
if (!empty($this->with)) {
$this->findWith($this->with, $models);
}
if ($this->inverseOf !== null) {
$this->addInverseRelations($models);
}
if (!$this->asArray) {
foreach ($models as $model) {
$model->afterFind();
}
}
return $models;
}
/** * @inheritdoc */ public function populate($rows) { $event = new PopulateEvent($this, $rows); $this->trigger(static::EVENT_BEFORE_POPULATE, $event); $rows = $event->rows; return parent::populate($rows); }