本文整理汇总了PHP中notification::send_message方法的典型用法代码示例。如果您正苦于以下问题:PHP notification::send_message方法的具体用法?PHP notification::send_message怎么用?PHP notification::send_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notification
的用法示例。
在下文中一共展示了notification::send_message方法的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;
}