public function findByUser($userOrId)
    {
        $userId = $userOrId instanceof \Auth\Entity\UserInterface ? $userOrId->getId() : $userOrId;
        $qb     = $this->createQueryBuilder();

        /*
         * HiringOrganizations also could be associated to the user, but we
         * do not want them to be queried here, so the query needs to check the
         * "parent" field, too.
         */
//        $qb->addAnd(
//           $qb->expr()->field('user')->equals($userId)
//                      ->addOr(
//                            $qb->expr()->addOr($qb->expr()->field('parent')->exists(false))
//                                       ->addOr($qb->expr()->field('parent')->equals(null))
//           )
//        );
        $qb->addAnd($qb->expr()->field('user')->equals($userId))
           ->addAnd(
               $qb->expr()->addOr($qb->expr()->field('parent')->exists(false))
                               ->addOr($qb->expr()->field('parent')->equals(null))
           );

        $q      = $qb->getQuery();
        $entity = $q->getSingleResult();

        return $entity;
    }
public function findByUser($userOrId)
    {
        $userId = $userOrId instanceof \Auth\Entity\UserInterface ? $userOrId->getId() : $userOrId;
        $qb     = $this->createQueryBuilder();

        /*
         * HiringOrganizations also could be associated to the user, but we
         * do not want them to be queried here, so the query needs to check the
         * "parent" field, too.
         */
//        $qb->addAnd(
//           $qb->expr()->field('user')->equals($userId)
//                      ->addOr(
//                            $qb->expr()->addOr($qb->expr()->field('parent')->exists(false))
//                                       ->addOr($qb->expr()->field('parent')->equals(null))
//           )
//        );
        $qb->addAnd($qb->expr()->field('user')->equals($userId))
           ->addAnd(
               $qb->expr()->addOr($qb->expr()->field('parent')->exists(false))
                               ->addOr($qb->expr()->field('parent')->equals(null))
           );

        $q      = $qb->getQuery();
        $entity = $q->getSingleResult();

        return $entity;
    }
public function findByUser ( $ userOrId ) { $ userId = $ userOrId instanceof \ Auth \ Entity \ UserInterface ? $ userOrId -> getId ( ) : $ userOrId ; $ qb = $ this -> createQueryBuilder ( ) ; /*
         * HiringOrganizations also could be associated to the user, but we
         * do not want them to be queried here, so the query needs to check the
         * "parent" field, too.
         */ //        $qb->addAnd( //           $qb->expr()->field('user')->equals($userId) //                      ->addOr( //                            $qb->expr()->addOr($qb->expr()->field('parent')->exists(false)) //                                       ->addOr($qb->expr()->field('parent')->equals(null)) //           ) //        ); $ qb -> addAnd ( $ qb -> expr ( ) -> field ( 'user' ) -> equals ( $ userId ) ) -> addAnd ( $ qb -> expr ( ) -> addOr ( $ qb -> expr ( ) -> field ( 'parent' ) -> exists ( false ) ) -> addOr ( $ qb -> expr ( ) -> field ( 'parent' ) -> equals ( null ) ) ) ; $ q = $ qb -> getQuery ( ) ; $ entity = $ q -> getSingleResult ( ) ; return $ entity ; }
Finds the main organization of an user.

@param string|UserInterface $userOrId

@return null|OrganizationInterface
Finds the main organization of an user .