protected function setTotalRows(Table $table)
    {
        $qb = $table->getQueryBuilder();
        $qbtr = clone $qb;

        $identifiers = $table->getIdentifierFieldNames();

        if (is_null($identifiers)) {
            $paginatorTotal = new Paginator($qbtr->getQuery());
            $count = $paginatorTotal->count();
        } else {
            $qbtr->select($qbtr->expr()->count($identifiers));
            $count = (int) $qbtr->getQuery()->getSingleScalarResult();
        }

        $table->setTotalRows($count);
    }