/**
  * Contains person with role
  *
  * @param Person|EmbeddedPerson $person
  * @param Role|EmbeddedRole     $role
  *
  * @return boolean
  */
 public function containsPersonWithRole($person, $role)
 {
     foreach ($this->getPeopleByRole($role, true) as $embeddedPerson) {
         if ($person->getId() == $embeddedPerson->getId()) {
             return true;
         }
     }
     return false;
 }
 /**
  * Update embedded person
  *
  * @param  Person         $person
  * @param  EmbeddedPerson $embeddedPerson
  * @return EmbeddedPerson
  */
 private function updateEmbeddedPerson(Person $person, EmbeddedPerson $embeddedPerson)
 {
     if (null !== $person) {
         $embeddedPerson->setName($person->getName());
         $embeddedPerson->setEmail($person->getEmail());
         $embeddedPerson->setWeb($person->getWeb());
         $embeddedPerson->setPhone($person->getPhone());
         $embeddedPerson->setI18nHonorific($person->getI18nHonorific());
         $embeddedPerson->setI18nFirm($person->getI18nFirm());
         $embeddedPerson->setI18nPost($person->getI18nPost());
         $embeddedPerson->setI18nBio($person->getI18nBio());
     }
     return $embeddedPerson;
 }
 public function testEmbeddedPerson()
 {
     $person = $this->createPerson('Person');
     $embeddedPerson = new EmbeddedPerson($person);
     $name = 'EmbeddedPerson';
     $web = 'http://www.url.com';
     $phone = '+34986123456';
     $honorific = 'honorific';
     $firm = 'firm';
     $post = 'post';
     $bio = 'biography';
     $locale = 'en';
     $embeddedPerson->setName($name);
     $embeddedPerson->setWeb($web);
     $embeddedPerson->setPhone($phone);
     $embeddedPerson->setHonorific($honorific);
     $embeddedPerson->setFirm($firm);
     $embeddedPerson->setPost($post);
     $embeddedPerson->setBio($bio);
     $embeddedPerson->setLocale($locale);
     $this->dm->persist($embeddedPerson);
     $this->dm->flush();
     $hname = $embeddedPerson->getHonorific() . ' ' . $embeddedPerson->getName();
     $other = $embeddedPerson->getPost() . ' ' . $embeddedPerson->getFirm() . ' ' . $embeddedPerson->getBio();
     $info = $embeddedPerson->getPost() . ', ' . $embeddedPerson->getFirm() . ', ' . $embeddedPerson->getBio();
     $this->assertEquals($name, $embeddedPerson->getName());
     $this->assertEquals($web, $embeddedPerson->getWeb());
     $this->assertEquals($phone, $embeddedPerson->getPhone());
     $this->assertEquals($honorific, $embeddedPerson->getHonorific());
     $this->assertEquals($firm, $embeddedPerson->getFirm());
     $this->assertEquals($post, $embeddedPerson->getPost());
     $this->assertEquals($bio, $embeddedPerson->getBio());
     $this->assertEquals($locale, $embeddedPerson->getLocale());
     $this->assertEquals($hname, $embeddedPerson->getHName());
     $this->assertEquals($other, $embeddedPerson->getOther());
     $this->assertEquals($info, $embeddedPerson->getInfo());
     $localeEs = 'es';
     $honorificEs = 'honores';
     $firmEs = 'firma';
     $postEs = 'publicacion';
     $bioEs = 'biografia';
     $honorificI18n = array($locale => $honorific, $localeEs => $honorificEs);
     $firmI18n = array($locale => $firm, $localeEs => $firmEs);
     $postI18n = array($locale => $post, $localeEs => $postEs);
     $bioI18n = array($locale => $bio, $localeEs => $bioEs);
     $embeddedPerson->setI18nHonorific($honorificI18n);
     $embeddedPerson->setI18nFirm($firmI18n);
     $embeddedPerson->setI18nPost($postI18n);
     $embeddedPerson->setI18nBio($bioI18n);
     $this->dm->persist($embeddedPerson);
     $this->dm->flush();
     $this->assertEquals($honorificI18n, $embeddedPerson->getI18nHonorific());
     $this->assertEquals($firmI18n, $embeddedPerson->getI18nFirm());
     $this->assertEquals($postI18n, $embeddedPerson->getI18nPost());
     $this->assertEquals($bioI18n, $embeddedPerson->getI18nBio());
     $honorific = null;
     $firm = null;
     $post = null;
     $bio = null;
     $embeddedPerson->setHonorific($honorific);
     $embeddedPerson->setFirm($firm);
     $embeddedPerson->setPost($post);
     $embeddedPerson->setBio($bio);
     $this->dm->persist($embeddedPerson);
     $this->dm->flush();
     $this->assertEquals($honorific, $embeddedPerson->getHonorific());
     $this->assertEquals($firm, $embeddedPerson->getFirm());
     $this->assertEquals($post, $embeddedPerson->getPost());
     $this->assertEquals($bio, $embeddedPerson->getBio());
 }
 /**
  * Contained embed person
  *
  * @param  Person|EmbeddedPerson  $person
  * @return EmbeddedPerson|boolean EmbeddedPerson if found, FALSE otherwise:
  */
 public function getEmbeddedPerson($person)
 {
     foreach ($this->people as $embeddedPerson) {
         if ($person->getId() === $embeddedPerson->getId()) {
             return $embeddedPerson;
         }
     }
     return false;
 }