本文整理汇总了PHP中Subject::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Subject::setName方法的具体用法?PHP Subject::setName怎么用?PHP Subject::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject::setName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetName
/**
* Test for setName.
*/
public function testSetName()
{
$subject = new Subject(array('name' => 'Mario', 'surname' => 'Rossi', 'birthDate' => '1985-12-10', 'gender' => 'M', 'belfioreCode' => 'A562'));
$subject->setName('Fabrizio');
$actual = $subject->getName();
$expected = 'Fabrizio';
$this->assertEquals($expected, $actual);
}
示例2: save
public function save()
{
$subjectId = $this->getValue('subjectId');
if (!empty($subjectId)) {
$subject = $this->getSubjectService()->getSubjectById($subjectId);
} else {
$subject = new Subject();
}
$subject->setCode($this->getValue('code'));
$subject->setName($this->getValue('name'));
$subject->save();
}
示例3: course_sort
public function course_sort($courseSections)
{
//First, we declare an array to hold subjects
$result = array();
//We get the name of the first element, then use that to re-sort each
//section by subject
while (count($courseSections) > 0) {
$name = reset($courseSections)->getCourse()->getCourseName();
$new_res = array_filter($courseSections, function ($elem) use($name) {
return $elem->getCourse()->getCourseName() === $name;
});
$courseSections = array_filter($courseSections, function ($elem) use($name) {
return $elem->getCourse()->getCourseName() != $name;
});
array_push($result, $new_res);
}
$copy = $result;
$result = array();
//Now that we have the subjects, we need to group sections into courses by course number
foreach ($copy as $r) {
$next = array();
while (count($r) > 0) {
$num = reset($r)->getCourse()->getCourseNumber();
$new_res = array_filter($r, function ($elem) use($num) {
return $elem->getCourse()->getCourseNumber() === $num;
});
$r = array_filter($r, function ($elem) use($num) {
return $elem->getCourse()->getCourseNumber() != $num;
});
array_push($next, $new_res);
}
array_push($result, $next);
}
/*$result = array_filter($result, function($elem)
{
return count($elem) > 0;
});*/
$copy = $result;
$result = array();
foreach ($copy as $res) {
foreach ($res as $r) {
usort($r, function ($a, $b) {
return $a->getSectionName() < $b->getSectionName() ? 1 : -1;
});
}
array_push($result, $res);
}
$copy = $result;
$result = array();
foreach ($copy as $r) {
usort($r, function ($a, $b) {
return reset($a)->getCourse()->getCourseNumber() > reset($b)->getCourse()->getCourseNumber() ? 1 : -1;
});
array_push($result, $r);
}
usort($result, function ($a, $b) {
return reset(reset($a))->getCourse()->getCourseName() > reset(reset($b))->getCourse()->getCourseName() ? 1 : -1;
});
$copy = $result;
$result = array();
foreach ($copy as $subj) {
$subject = new Subject();
$subject->setName(reset(reset($subj))->getCourse()->getCourseName());
$subject->setTitle(reset(reset($subj))->getCourse()->getCourseCategoryName());
$courses = array();
foreach ($subj as $crs) {
$course = new Course();
$course->setName(reset($crs)->getCourse()->getCourseNumber());
$course->setTitle(reset($crs)->getCourse()->getCourseTitle());
$course->setHours(reset($crs)->getHours());
$course->setSections($crs);
array_push($courses, $course);
}
$subject->setCourses($courses);
array_push($result, $subject);
}
return $result;
}
示例4: executeUpdate
public function executeUpdate()
{
$i18n = new sfI18N();
$i18n->initialize($this->getContext());
$i18n->setCulture($this->getUser()->getCulture());
$action_i18n = $i18n->globalMessageFormat->format('save as new');
$action_type = $this->getRequestParameter('action_type');
if ($action_type == $action_i18n || !$this->getRequestParameter('id')) {
$subject = new Subject();
$subject->setCode($this->getRequestParameter('code'));
$subject->setName($this->getRequestParameter('name'));
$subject->setCredit($this->getRequestParameter('credit'));
$subject->setSubjectGroupId($this->getRequestParameter('subject_group_id'));
$subject->setDepartmentId($this->getRequestParameter('department_id'));
$subject->save();
#$subject_curr = new SubjectCurr();
#$subject_curr->setSubject($subject);
#$subject_curr->setCurriculumId($this->getRequestParameter('curriculum_id'));
#$subject_curr->save();
#$c = new Criteria();
#$c->add(AcademicCalendarPeer::CURRICULUM_ID, $this->getRequestParameter('curriculum_id'));
#$currs = AcademicCalendarPeer::doSelect($c);
#foreach ($currs as $curr) {
# $subject_accal = new SubjectAccal();
# $subject_accal->setSubject($subject);
# $subject_accal->setAcademicCalendarId($curr->getId());
# $subject_accal->setEmployeeId($this->getRequestParameter('employee_id'));
# $subject_accal->save();
# $subject_accal_lector = new SubjectAccalLector();
# $subject_accal_lector->setSubjectAccal($subject_accal);
# $subject_accal_lector->setEmployeeId($this->getRequestParameter('employee_id'));
# $subject_accal_lector->save();
#}
$subject_accal = new SubjectAccal();
$subject_accal->setSubject($subject);
$subject_accal->setAcademicCalendarId($this->getRequestParameter('academic_calendar_id'));
$subject_accal->setEmployeeId($this->getRequestParameter('employee_id'));
$subject_accal->save();
#$subject_accal_lector = new SubjectAccalLector();
#$subject_accal_lector->setSubjectAccal($subject_accal);
#$subject_accal_lector->setEmployeeId($this->getRequestParameter('employee_id'));
#$subject_accal_lector->save();
} else {
$subject = SubjectPeer::retrieveByPk($this->getRequestParameter('id'));
$this->forward404Unless($subject);
$subject->setId($this->getRequestParameter('id'));
$subject->setCode($this->getRequestParameter('code'));
$subject->setName($this->getRequestParameter('name'));
$subject->setCredit($this->getRequestParameter('credit'));
$subject->setSubjectGroupId($this->getRequestParameter('subject_group_id'));
$subject->setDepartmentId($this->getRequestParameter('department_id'));
$subject->save();
$c = new Criteria();
$c->add(SubjectAccalPeer::ID, $this->getRequestParameter('subject_accal_id'));
$subject_accal = SubjectAccalPeer::doSelectOne($c);
#$subject_accal = SubjectAccalPeer::retrieveByPk($this->getRequestParameter('subject_accal_id'));
#$this->forward404Unless($subject_accal);
$subject_accal->setId('subject_accal_id');
$subject_accal->setSubject($subject);
$subject_accal->setAcademicCalendarId($this->getRequestParameter('academic_calendar_id'));
$subject_accal->setEmployeeId($this->getRequestParameter('employee_id'));
$subject_accal->save();
}
return $this->redirect('subject/list');
}
示例5:
<option value="4" selected>4</option>
</select>
</div>
</fieldset>
<fieldset class="buttons">
<button type="reset">RESET</button>
<button type="submit"
name="stage"
value="2">submit</button>
</fieldset>
</form>
</div>';
break;
case "2":
$subject->setCode($_POST["code"]);
$subject->setName($_POST["name"]);
$subject->setDescription($_POST["description"]);
$subject->setStartYear($_POST["startYear"]);
$subject->setStopYear($_POST["stopYear"]);
if ($subject->validate()) {
if ($subject->update()) {
$pageBody .= '
<table>
<tbody>
<tr>
<th>code</th>
<td>' . $subject->getCode() . '</td>
</tr>
<tr>
<th>name</th>
<td>' . $subject->getName() . '</td>