當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Component::setComponent方法代碼示例

本文整理匯總了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');
}
開發者ID:Eurymone,項目名稱:Student-Exam-Report-System,代碼行數:31,代碼來源:exam_save.php


注:本文中的Component::setComponent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。