Ejemplo n.º 1
0
 public function getContacts()
 {
     if ($this->isSuperAdmin) {
         $user = $this->om->getRepository('UserBundle:User')->find(1);
         $contact = new Contact();
         $contact->setUsername($user->getUsername())->setEmail($user->getEmail());
         return array($contact);
     }
     $contacts = array();
     $emails = array();
     foreach ($this->getUsers() as $user) {
         if (!in_array($email = $user->getEmail(), $emails)) {
             $emails[] = $email;
             $contact = new Contact();
             $contact->setEmail($email)->setUsername($user->getUsername());
             $contacts[] = $contact;
         }
     }
     foreach ($this->getNewsletters() as $newsletter) {
         if (!in_array($email = $newsletter->getMail(), $emails)) {
             $emails[] = $email;
             $contact = new Contact();
             $contact->setEmail($email)->setToken($newsletter->getToken())->setUnSubscribable(true);
             $contacts[] = $contact;
         }
     }
     return $contacts;
 }
Ejemplo n.º 2
0
 public function getContacts()
 {
     $user = $this->om->getRepository('UserBundle:User')->find($this->id);
     if (null === $user) {
         throw new \InvalidArgumentException(sprintf("User with id[%s] doesn't exist.", $this->id));
     }
     $contact = new Contact();
     $contact->setEmail($user->getEmail())->setUsername($user->getUsername());
     return array($contact);
 }