Exemplo n.º 1
0
 public function saveCorrelativeCareerSubjectId($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['correlative_career_subject_id'])) {
         // somebody has unset this widget
         return;
     }
     if (is_null($con)) {
         $con = $this->getConnection();
     }
     /* First try to delete old correlatives */
     $criteria = new Criteria();
     $criteria->add(CorrelativePeer::CAREER_SUBJECT_ID, $this->getObject()->getCareerSubjectId());
     CorrelativePeer::doDelete($criteria, $con);
     /* Now set new values */
     $values = $this->getValue('correlative_career_subject_id');
     if (is_array($values)) {
         foreach ($values as $value) {
             $correlative = new Correlative();
             $correlative->setCareerSubjectId($this->getObject()->getCareerSubjectId());
             $correlative->setCorrelativeCareerSubjectId($value);
             $correlative->save($con);
         }
     }
 }
Exemplo n.º 2
0
 public function createCorrelatives()
 {
     foreach ($this->getCareerSubjectRelatedByCareerSubjectId()->getCorrelatives() as $correlative) {
         $new_correlative = new Correlative();
         $new_correlative->setCareerSubjectId($this->getOptionalCareerSubjectId());
         $new_correlative->setCorrelativeCareerSubjectId($correlative->getCorrelativeCareerSubjectId());
         $new_correlative->save();
     }
 }