yii\validators\ExistValidator::createQuery PHP Method

createQuery() protected method

Creates a query instance with the given condition.
protected createQuery ( string $targetClass, mixed $condition ) : yii\db\ActiveQueryInterface
$targetClass string the target AR class
$condition mixed query condition
return yii\db\ActiveQueryInterface the query instance
    protected function createQuery($targetClass, $condition)
    {
        /* @var $targetClass \yii\db\ActiveRecordInterface */
        $query = $targetClass::find()->andWhere($condition);
        if ($this->filter instanceof \Closure) {
            call_user_func($this->filter, $query);
        } elseif ($this->filter !== null) {
            $query->andWhere($this->filter);
        }
        return $query;
    }