本文整理匯總了PHP中notification::prepare_data方法的典型用法代碼示例。如果您正苦於以下問題:PHP notification::prepare_data方法的具體用法?PHP notification::prepare_data怎麽用?PHP notification::prepare_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類notification
的用法示例。
在下文中一共展示了notification::prepare_data方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: notify
/**
* Takes notification data and sends a message or email.
* Expected data:
* - sender => stdClass (User object)
* - subject => string
* - content => string
* - contentformat => int (e.g. FORMAT_HTML). Optional; default FORMAT_PLAIN
* - notification => bool|int
* - recipients => array (Array of user objects)
* - recipientemails => array (Array of email addresses)
*
* @param array $data Notification data
* @return array
*/
public static function notify(\core\event\base $event)
{
$dataformid = $event->other['dataid'];
$man = \mod_dataform_notification_manager::instance($dataformid);
$result = false;
if ($rules = $man->get_type_rules_enabled()) {
$params = array();
$params['event'] = $event->eventname;
$params['dataformid'] = $dataformid;
$params['viewid'] = !empty($event->other['viewid']) ? $event->other['viewid'] : null;
$params['entryid'] = !empty($event->other['entryid']) ? $event->other['entryid'] : null;
foreach ($rules as $rule) {
if ($rule->is_applicable($params)) {
$notification = new notification();
$message = $notification->prepare_data($event, $rule);
$result = ($result or $notification->send_message($message));
}
}
}
return $result;
}