本文整理汇总了PHP中Contest::setChallenges方法的典型用法代码示例。如果您正苦于以下问题:PHP Contest::setChallenges方法的具体用法?PHP Contest::setChallenges怎么用?PHP Contest::setChallenges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contest
的用法示例。
在下文中一共展示了Contest::setChallenges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onSubmit
/**
* Process the form. At this point we know that the user passes all the criteria in
* userCanExecute(), and if the data array contains 'Username', etc, then Username
* resets are allowed.
*
* @param array $data
*
* @return Bool|Array
*/
public function onSubmit(array $data)
{
$fields = array();
foreach ($data as $name => $value) {
$matches = array();
if (preg_match('/contest-(.+)/', $name, $matches)) {
if ($matches[1] == 'end') {
$value = wfTimestamp(TS_MW, strtotime($value));
}
$fields[$matches[1]] = $value;
}
}
// If no ID is set, this means it's a new contest, so set the ID to null for an insert.
// However, the user can have hot the back button after creation of a new contest,
// re-submitting the form. In this case, get the ID of the already existing item for an update.
if (!array_key_exists('id', $fields) || $fields['id'] === '') {
$contest = Contest::s()->selectRow('id', array('name' => $fields['name']));
$fields['id'] = $contest === false ? null : $contest->getField('id');
}
$contest = new Contest($fields, is_null($fields['id']));
$contest->setChallenges($this->getSubmittedChallenges());
$success = $contest->writeAllToDB();
$success = $this->removeDeletedChallenges($data['delete-challenges']) && $success;
if ($success) {
return true;
} else {
return array();
// TODO
}
}