/**
  * @param QueryBuilder $qb
  * @return integer|null
  * @throws \Exception
  */
 private function applyFilterAndCount(QueryBuilder $qb)
 {
     if (null === $this->request->getSearchValue() && !$this->table->getHasColumnFilter()) {
         return null;
     }
     $filter = [];
     foreach ($this->table->getColumns() as $column) {
         if ($column instanceof EntitiesCountColumn || true === $column->getOptions()['unbound']) {
             continue;
         }
         $field = $this->getPrefixedField($column);
         if (false !== $column->getOptions()['filter'] || true === $column->getOptions()['filter_empty']) {
             $value = $this->request->getSearchValue($column->getName());
             $empty = null;
             if (true === $column->getOptions()['filter_empty']) {
                 $empty = $this->extractEmptyFilterFromValue($value);
             }
             if (null !== $value || null !== $empty) {
                 $this->applyColumnFilter($column, $value, $qb, $field, $empty);
                 continue;
             }
         }
         $filter[] = $field;
     }
     if (null !== $this->request->getSearchValue()) {
         $where = '(' . join(' like :filter OR ', $filter) . ' like :filter)';
         $qb->andWhere($where);
         $qb->setParameter('filter', '%' . $this->request->getSearchValue() . '%');
     }
     return $qb->getQuery()->getSingleScalarResult();
 }