Newscoop\Entity\Repository\FeedbackRepository::buildFilter PHP Method

buildFilter() protected method

Build filter condition
protected buildFilter ( array $cols, array $filter, $qb, $andx ) : Doctrine\ORM\Query\Expr
$cols array
$filter array
$qb
$andx
return Doctrine\ORM\Query\Expr
    protected function buildFilter(array $cols, array $filter, $qb, $andx)
    {
        foreach ($filter as $key => $values) {
            if (!is_array($values)) {
                $values = array($values);
            }
            $orx = $qb->expr()->orx();
            switch ($key) {
                case 'status':
                    $mapper = array_flip(Feedback::$status_enum);
                    foreach ($values as $value) {
                        $orx->add($qb->expr()->eq('e.status', $mapper[$value]));
                    }
                    break;
                case 'attachmentType':
                    $mapper = array_flip(Feedback::$attachment_type_enum);
                    foreach ($values as $value) {
                        $orx->add($qb->expr()->eq('e.attachment_type', $mapper[$value]));
                    }
            }
            $andx->add($orx);
        }
        return $andx;
    }