本文整理汇总了PHP中badge::save方法的典型用法代码示例。如果您正苦于以下问题:PHP badge::save方法的具体用法?PHP badge::save怎么用?PHP badge::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类badge
的用法示例。
在下文中一共展示了badge::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_badge_updated
/**
* Test the badge updated event.
*
*/
public function test_badge_updated()
{
$badge = new badge($this->badgeid);
$sink = $this->redirectEvents();
// Trigger and capture the event.
$badge->save();
$events = $sink->get_events();
$event = reset($events);
$this->assertCount(1, $events);
// Check that the event data is valid.
$this->assertInstanceOf('\\core\\event\\badge_updated', $event);
$this->assertEquals($badge->id, $event->objectid);
$this->assertDebuggingNotCalled();
$sink->close();
}
示例2: badges_process_badge_image
/**
* Process badge image from form data
*
* @param badge $badge Badge object
* @param string $iconfile Original file
*/
function badges_process_badge_image(badge $badge, $iconfile)
{
global $CFG, $USER;
require_once $CFG->libdir . '/gdlib.php';
if (!empty($CFG->gdversion)) {
if ($fileid = (int) process_new_icon($badge->get_context(), 'badges', 'badgeimage', $badge->id, $iconfile)) {
$badge->image = $fileid;
$badge->save();
}
@unlink($iconfile);
// Clean up file draft area after badge image has been saved.
$context = context_user::instance($USER->id, MUST_EXIST);
$fs = get_file_storage();
$fs->delete_area_files($context->id, 'user', 'draft');
}
}