Ejemplo n.º 1
0
 public function getDynamicUsers(\Club\UserBundle\Entity\Group $group)
 {
     $filter = new \Club\UserBundle\Entity\Filter();
     if ($group->getGender() != null) {
         $attr = new \Club\UserBundle\Entity\FilterAttribute();
         $attr->setAttribute('gender');
         $attr->setValue($group->getGender());
         $filter->addAttributes($attr);
     }
     if ($group->getMaxAge() != null) {
         $attr = new \Club\UserBundle\Entity\FilterAttribute();
         $attr->setAttribute('max_age');
         $attr->setValue($group->getMaxAge());
         $filter->addAttributes($attr);
     }
     if ($group->getMinAge() != null) {
         $attr = new \Club\UserBundle\Entity\FilterAttribute();
         $attr->setAttribute('min_age');
         $attr->setValue($group->getMinAge());
         $filter->addAttributes($attr);
     }
     if ($group->getActiveMember() != null) {
         $attr = new \Club\UserBundle\Entity\FilterAttribute();
         $attr->setAttribute('active');
         $attr->setValue(1);
         $filter->addAttributes($attr);
     }
     return $this->_em->getRepository('ClubUserBundle:User')->getUsers($filter);
 }
Ejemplo n.º 2
0
 public function getQueryByGroup(\Club\UserBundle\Entity\Group $group)
 {
     $qb = $this->getQueryBuilder();
     if ($group->getGender() != '') {
         $qb = $this->filterGender($qb, $group->getGender());
     }
     if ($group->getMinAge() != '') {
         $qb = $this->filterMinAge($qb, $group->getMinAge());
     }
     if ($group->getMaxAge() != '') {
         $qb = $this->filterMaxAge($qb, $group->getMaxAge());
     }
     if ($group->getActiveMember() != '') {
         $qb = $this->filterActive($qb, $group->getActiveMember());
     }
     if (count($group->getLocation()) > 0) {
         $location_arr = array();
         foreach ($group->getLocation() as $location) {
             $location_arr[] = $location->getId();
         }
         $qb = $this->filterLocation($qb, $location_arr);
     }
     return $qb->getQuery();
 }