protected function addPagination(QueryBuilder $queryBuilder, $elementsPerPage, $page = 1)
    {
        $elementsPerPage = (int)$elementsPerPage;
        $page = (int)$page;

        return $queryBuilder
            ->setMaxResults($elementsPerPage)
            ->setFirstResult($elementsPerPage * ($page - 1));
    }