public static function setCriteria(QueryBuilder $queryBuilder, array $criteria = [], $alias = null)
    {
        /*
         * No criteria used in WHERE clause?
         * Nothing to do
         */
        if (empty($criteria)) {
            return $queryBuilder;
        }

        /*
         * No alias provided?
         * Let's use root alias
         */
        if (null === $alias || '' === $alias) {
            $alias = self::getRootAlias($queryBuilder);
        }

        foreach ($criteria as $column => $value) {
            $compareOperator = '=';

            if (is_array($value) && !empty($value)) {
                if (2 === count($value)) {
                    $compareOperator = $value[1];
                }

                $value = $value[0];
            }

            $predicate = sprintf('%s.%s %s :%s', $alias, $column, $compareOperator, $column);

            if (null === $value) {
                $predicate = $queryBuilder->expr()->isNull(sprintf('%s.%s', $alias, $column));
                unset($criteria[$column]);
            } else {
                $queryBuilder->setParameter($column, $value);
            }

            $queryBuilder = $queryBuilder->andWhere($predicate);
        }

        return $queryBuilder;
    }