main/core/Repository/Facet/FacetRepository.php
public function findVisibleFacets(TokenInterface $token, $isRegistration = false)
    {
        // retrieves current user roles
        $roleNames = array_map(function (Role $role) {
            return $role->getRole();
        }, $token->getRoles());

        $qb = $this->createQueryBuilder('f');

        if ($isRegistration) {
            $qb->andWhere('f.forceCreationForm = true');
        } else {
            if (!in_array('ROLE_ADMIN', $roleNames)) {
                // filter query to only get accessible facets for the current roles
                $qb
                  ->leftJoin('f.roles', 'r')
                  ->where('(r.id IS NULL OR r.name IN (:roles))')
                  ->setParameter('roles', $roleNames);
            }
        }

        $qb->orderBy('f.main DESC, f.position');

        return $qb->getQuery()->getResult();
    }
public function findVisibleFacets(TokenInterface $token, $isRegistration = false)
    {
        // retrieves current user roles
        $roleNames = array_map(function (Role $role) {
            return $role->getRole();
        }, $token->getRoles());

        $qb = $this->createQueryBuilder('f');

        if ($isRegistration) {
            $qb->andWhere('f.forceCreationForm = true');
        } else {
            if (!in_array('ROLE_ADMIN', $roleNames)) {
                // filter query to only get accessible facets for the current roles
                $qb
                  ->leftJoin('f.roles', 'r')
                  ->where('(r.id IS NULL OR r.name IN (:roles))')
                  ->setParameter('roles', $roleNames);
            }
        }

        $qb->orderBy('f.main DESC, f.position');

        return $qb->getQuery()->getResult();
    }
public function findVisibleFacets ( TokenInterface $ token , $ isRegistration = false ) { // retrieves current user roles $ roleNames = array_map ( function ( Role $ role ) { return $ role -> getRole ( ) ; } , $ token -> getRoles ( ) ) ; $ qb = $ this -> createQueryBuilder ( 'f' ) ; if ( $ isRegistration ) { $ qb -> andWhere ( 'f.forceCreationForm = true' ) ; } else { if ( ! in_array ( 'ROLE_ADMIN' , $ roleNames ) ) { // filter query to only get accessible facets for the current roles $ qb -> leftJoin ( 'f.roles' , 'r' ) -> where ( '(r.id IS NULL OR r.name IN (:roles))' ) -> setParameter ( 'roles' , $ roleNames ) ; } } $ qb -> orderBy ( 'f.main DESC, f.position' ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; }
Find facets visible by the current User.

@param TokenInterface $token
@param bool           $isRegistration

@return Facet[]
Find facets visible by the current User .