public function save() { $origin_career_school_year = CareerSchoolYearPeer::retrieveByPk($this->getValue('career_school_year_id')); $destiny_career_school_year = CareerSchoolYearPeer::retrieveByPk($this->getOption('destiny_career_id')); $last_year_school_year = SchoolYearPeer::retrieveLastYearSchoolYear(SchoolYearPeer::retrieveCurrent()); $students = CareerStudentPeer::retrieveLastYearCareerGraduatedStudents($origin_career_school_year); $con = Propel::getConnection(); try { $con->beginTransaction(); foreach ($students as $student) { $student->registerToCareer($destiny_career_school_year->getCareer(), null, null, $destiny_career_school_year->getCareer()->getMinYear(), $con); $shift = $student->getShiftForSchoolYear($last_year_school_year); if (!$student->getIsRegistered($destiny_career_school_year->getSchoolYear())) { $student->registerToSchoolYear($destiny_career_school_year->getSchoolYear(), $shift, $con); } } $con->commit(); } catch (PropelException $e) { $con->rollBack(); throw $e; } }