Example #1
0
 /**
  * Method addSystem_program
  * Add a System_program to the System_group
  * @param $object Instance of System_program
  */
 public function addSystemProgram(SystemProgram $systemprogram)
 {
     $object = new SystemGroupProgram();
     $object->system_program_id = $systemprogram->id;
     $object->system_group_id = $this->id;
     $object->store();
 }
 /**
  * Store the object and its aggregates
  */
 public function store()
 {
     // store the object itself
     parent::store();
     // delete the related System_groupSystem_program objects
     $criteria = new TCriteria();
     $criteria->add(new TFilter('system_group_id', '=', $this->id));
     $repository = new TRepository('SystemGroupProgram');
     $repository->delete($criteria);
     // store the related System_groupSystem_program objects
     if ($this->system_programs) {
         foreach ($this->system_programs as $system_program) {
             $system_group_system_program = new SystemGroupProgram();
             $system_group_system_program->system_program_id = $system_program->id;
             $system_group_system_program->system_group_id = $this->id;
             $system_group_system_program->store();
         }
     }
 }