本文整理匯總了PHP中Component::setComponent方法的典型用法代碼示例。如果您正苦於以下問題:PHP Component::setComponent方法的具體用法?PHP Component::setComponent怎麽用?PHP Component::setComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Component
的用法示例。
在下文中一共展示了Component::setComponent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: foreach
if ($role === 'Professor') {
$componentsScheduled = ComponentDAL::findByModule($module);
foreach ($componentsScheduled as $componentScheduled) {
$typeScheduled = $componentScheduled->getType();
if (!$componentScheduled->getIsResit() && $typeScheduled->getId() == $type) {
$_SESSION['message']['warning'] = 'An ' . $typeScheduled->getTypeName() . ' has already been scheduled (' . $componentScheduled->getDate() . ') for this module.';
header('Location: ../administration/schedule');
die;
}
}
$usersHaveModule = UserHasModuleDAL::findByModule($module);
if (count($usersHaveModule) == 0) {
$_SESSION['message']['warning'] = 'There is no student assigned to this module.';
header('Location: ../administration/schedule');
die;
}
foreach ($usersHaveModule as $userHasModule) {
$component = new Component(0, 0, $dateSchedule, false);
$component->setType($type);
$component->setComponent(0);
$component->setModule($module);
$component->setUser($userHasModule->getUserId());
ComponentDAL::flush($component);
}
$_SESSION['message']['success'] = 'Your exam has been scheduled with success.';
header('Location: ../administration/schedule');
} else {
// 403
$_SESSION['message']['danger'] = 'You can\'t access this page.';
header('Location: ../home');
}