Example #1
0
 public function setMother(PersonaInterface $mother = null)
 {
     if ($mother instanceof PersonaInterface) {
         if ($this->parentsValidator->isValidMother($this, $mother)) {
             $this->mother = $mother;
             if (!$this->mother->getChildren()->contains($this)) {
                 $this->mother->addChild($this);
             }
         } else {
             $this->throwValidationErrors($this->parentsValidator);
         }
     }
 }
 /**
  *
  *
  * @param PersonaInterface $persona
  * @param \ArrayAccess $data
  * @param int $options
  * @return return_type
  */
 protected function fetchChildren(PersonaInterface $persona, \ArrayAccess $data, $options)
 {
     $parentColumnName = $persona->getGender() === $persona::GENDER_MALE ? 'father_id' : 'mother_id';
     $childrenRows = $this->createTableGateway($this->tableName)->select([$parentColumnName => $persona->getId()]);
     foreach ($childrenRows as $childRow) {
         $child = $this->getPersonaById($childRow['id'], $options);
         if (!$persona->getChildren()->contains($child)) {
             $persona->addChild($child);
         }
     }
 }