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);
 }
 /**
  * Syncronize a data column
  */
 private function syncColumn($filter, $column, $value)
 {
     $em = $this->getDoctrine()->getManager();
     $attr = $em->getRepository('ClubUserBundle:FilterAttribute')->findOneBy(array('filter' => $filter->getId(), 'attribute' => $column));
     if (!strlen($value) && $attr) {
         $em->remove($attr);
     } elseif (strlen($value)) {
         if (!$attr) {
             $attr = new \Club\UserBundle\Entity\FilterAttribute();
             $attr->setFilter($filter);
             $attr->setAttribute($column);
         }
         $attr->setValue($value);
         $em->persist($attr);
     }
 }
Beispiel #3
0
 public function createFilter(\Club\UserBundle\Entity\User $user)
 {
     $filter = new \Club\UserBundle\Entity\Filter();
     $filter->setFilterName('Working');
     $filter->setActive(0);
     $filter->setUser($user);
     $attributes = $this->_em->getRepository('ClubUserBundle:Attribute')->findAll();
     foreach ($attributes as $attr) {
         $filter_attr = new \Club\UserBundle\Entity\FilterAttribute();
         $filter_attr->setFilter($filter);
         $filter_attr->setAttribute($attr);
         $filter->addAttributes($filter_attr);
         $this->_em->persist($filter_attr);
     }
     $this->_em->persist($filter);
     return $filter;
 }