diff --git a/Entity/Person.php b/Entity/Person.php index 6b29261e2..5805cffcb 100644 --- a/Entity/Person.php +++ b/Entity/Person.php @@ -23,6 +23,7 @@ namespace Chill\PersonBundle\Entity; use Symfony\Component\Validator\ExecutionContextInterface; use Chill\MainBundle\Entity\Country; +use Doctrine\Common\Collections\ArrayCollection; /** * Person @@ -104,16 +105,22 @@ class Person { * @var string */ private $phonenumber = ''; + + /** + * The spoken languages (ArrayCollection of Languages) + * @var \Doctrine\Common\Collections\ArrayCollection + */ + private $spokenLanguages; public function __construct(\DateTime $opening = null) { - $this->history = new \Doctrine\Common\Collections\ArrayCollection(); + $this->history = new ArrayCollection(); + $this->spokenLanguages = new ArrayCollection(); if ($opening === null) { $opening = new \DateTime(); } $this->open(new PersonHistoryFile($opening)); - } /** @@ -530,7 +537,29 @@ class Person { { return $this->getLabel(); } - + + /** + * Set spokenLanguages + * + * @param type $spokenLanguages + * @return Person + */ + public function setSpokenLanguages($spokenLanguages) + { + $this->spokenLanguages = $spokenLanguages; + + return $this; + } + + /** + * Get spokenLanguages + * + * @return ArrayCollection + */ + public function getSpokenLanguages() + { + return $this->spokenLanguages; + } // VALIDATION public function isHistoryValid(ExecutionContextInterface $context) { diff --git a/Form/PersonType.php b/Form/PersonType.php index a6386877d..868ffc85f 100644 --- a/Form/PersonType.php +++ b/Form/PersonType.php @@ -53,6 +53,10 @@ class PersonType extends AbstractType ->add('nationality', 'select2_chill_country', array( 'required' => false )) + ->add('spokenLanguages', 'select2_chill_language', array( + 'required' => false, + 'multiple' => true + )) ; if($options['cFGroup']) { diff --git a/Resources/config/doctrine/Person.orm.yml b/Resources/config/doctrine/Person.orm.yml index ec381acbe..79bd43ce7 100644 --- a/Resources/config/doctrine/Person.orm.yml +++ b/Resources/config/doctrine/Person.orm.yml @@ -53,4 +53,9 @@ Chill\PersonBundle\Entity\Person: targetEntity: PersonHistoryFile mappedBy: person cascade: [persist, remove, merge, detach] + manyToMany: + spokenLanguages: + targetEntity: Chill\MainBundle\Entity\Language + joinTable: + name: persons_spoken_languages lifecycleCallbacks: { }