本文整理汇总了PHP中base::create方法的典型用法代码示例。如果您正苦于以下问题:PHP base::create方法的具体用法?PHP base::create怎么用?PHP base::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base
的用法示例。
在下文中一共展示了base::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public static function create(\stdClass $data)
{
if ($data->mode == 'youtube') {
$data->galleryfocus = self::TYPE_VIDEO;
}
if (empty($data->groupid)) {
$data->groupid = 0;
}
$result = parent::create($data);
$params = array('context' => $result->get_collection()->context, 'objectid' => $result->id);
if (!empty($data->nosync)) {
$params['other']['nosync'] = true;
}
if (empty($data->noevent)) {
$event = \mod_mediagallery\event\gallery_created::create($params);
$event->add_record_snapshot('mediagallery_gallery', $result->get_record());
$event->trigger();
}
return $result;
}
示例2: create
public static function create(\stdClass $data)
{
global $DB, $USER;
foreach (static::$defaultvalues as $key => $val) {
if (!isset($data->{$key})) {
$data->{$key} = $val;
}
}
$data->timecreated = time();
if (!isset($data->userid)) {
$data->userid = $USER->id;
}
$result = parent::create($data);
if (!empty($data->thumbnail)) {
$sql = "UPDATE {mediagallery_gallery}\n SET thumbnail = :item\n WHERE id = :galleryid";
$DB->execute($sql, array('item' => $result->id, 'galleryid' => $result->galleryid));
}
$params = array('context' => $result->get_context(), 'objectid' => $result->id);
if (!empty($data->nosync)) {
$params['other']['nosync'] = true;
}
$event = \mod_mediagallery\event\item_created::create($params);
$event->add_record_snapshot('mediagallery_item', $result->get_record());
$event->trigger();
return $result;
}