getRolesQueryBuilder example


    public function getRolesAction()
    {
        $limit = (int) $this->Request()->getParam('limit', 20);
        $offset = (int) $this->Request()->getParam('start', 0);
        $id = $this->Request()->getParam('id', null);

        if ($id !== null) {
            $queryBuilder = $this->getUserRepository()->getRolesQueryBuilder();
            $query = $queryBuilder
                ->setFirstResult(0)
                ->setMaxResults(1)
                ->andWhere('roles.id = :role_id')
                ->setParameter(':role_id', (int) $id)
                ->getQuery();
            $count = 1;
        } else {
            $query = $this->getUserRepository()
                ->getRolesQuery($offset$limit);
            $count = $this->get('models')->getQueryCount($query);
        }
/** * Returns an instance of the \Doctrine\ORM\Query object which select a list of roles. * * @param int|null $offset * @param int|null $limit * * @return Query<Role> */
    public function getRolesQuery($offset = null, $limit = null)
    {
        $builder = $this->getRolesQueryBuilder();
        if ($limit !== null) {
            $builder->setFirstResult($offset)
                    ->setMaxResults($limit);
        }

        return $builder->getQuery();
    }

    /** * Helper function to create the query builder for the "getRolesQuery" function. * This function can be hooked to modify the query builder of the query object. * * @return QueryBuilder */
Home | Imprint | This part of the site doesn't use cookies.