コード例 #1
0
 private function getNewsletterGroupsOfStudent(Estudiante $estudiante)
 {
     $toAddGroups = array();
     if ($estudiante->getActive()) {
         if ($estudiante->getEgresado()) {
             $newsLetterUserGroup = $this->em->getRepository('MaithNewsletterBundle:UserGroup')->findOneBy(array('name' => 'EGRESADOS'));
             if ($newsLetterUserGroup) {
                 $toAddGroups[$newsLetterUserGroup->getId()] = $newsLetterUserGroup;
             }
         } else {
             if ($estudiante->getAnioIngreso()) {
                 $today = new \DateTime();
                 if ($today->format('Y') <= $estudiante->getAnioIngreso()) {
                     $newsLetterUserGroup = $this->em->getRepository('MaithNewsletterBundle:UserGroup')->findOneBy(array('name' => 'Futuros'));
                     if ($newsLetterUserGroup) {
                         $toAddGroups[$newsLetterUserGroup->getId()] = $newsLetterUserGroup;
                     }
                 } else {
                     $newsLetterUserGroup = $this->em->getRepository('MaithNewsletterBundle:UserGroup')->findOneBy(array('name' => 'PADRES'));
                     if ($newsLetterUserGroup) {
                         $toAddGroups[$newsLetterUserGroup->getId()] = $newsLetterUserGroup;
                     }
                     if ($estudiante->getClase() && $estudiante->getHorario()) {
                         $newsLetterUserGroup = $this->em->getRepository('MaithNewsletterBundle:UserGroup')->findOneBy(array('name' => $estudiante->getClase()->getName() . ' (' . $estudiante->getHorario()->getName() . ')'));
                         $toAddGroups[$newsLetterUserGroup->getId()] = $newsLetterUserGroup;
                     }
                 }
             }
             foreach ($estudiante->getActividades() as $actividad) {
                 $toAddGroups[$actividad->getNewsLetterGroup()->getId()] = $actividad->getNewsLetterGroup();
             }
         }
     }
     return $toAddGroups;
 }