yii\db\ActiveRelationTrait::filterByModels PHP Method

filterByModels() private method

private filterByModels ( array $models )
$models array
    private function filterByModels($models)
    {
        $attributes = array_keys($this->link);
        $attributes = $this->prefixKeyColumns($attributes);
        $values = [];
        if (count($attributes) === 1) {
            // single key
            $attribute = reset($this->link);
            foreach ($models as $model) {
                if (($value = $model[$attribute]) !== null) {
                    if (is_array($value)) {
                        $values = array_merge($values, $value);
                    } else {
                        $values[] = $value;
                    }
                }
            }
            if (empty($values)) {
                $this->emulateExecution();
            }
        } else {
            // composite keys
            // ensure keys of $this->link are prefixed the same way as $attributes
            $prefixedLink = array_combine($attributes, array_values($this->link));
            foreach ($models as $model) {
                $v = [];
                foreach ($prefixedLink as $attribute => $link) {
                    $v[$attribute] = $model[$link];
                }
                $values[] = $v;
                if (empty($v)) {
                    $this->emulateExecution();
                }
            }
        }
        $this->andWhere(['in', $attributes, array_unique($values, SORT_REGULAR)]);
    }