本文整理汇总了PHP中AuditEvent::getTailDistinctEventsByEventName方法的典型用法代码示例。如果您正苦于以下问题:PHP AuditEvent::getTailDistinctEventsByEventName方法的具体用法?PHP AuditEvent::getTailDistinctEventsByEventName怎么用?PHP AuditEvent::getTailDistinctEventsByEventName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuditEvent
的用法示例。
在下文中一共展示了AuditEvent::getTailDistinctEventsByEventName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetTailDistinctEventsByEventName
public function testGetTailDistinctEventsByEventName()
{
Yii::app()->user->userModel = User::getByUsername('super');
$account1 = new Account();
$account1->name = 'Dooble1';
$this->assertTrue($account1->save());
$account2 = new Account();
$account2->name = 'Dooble2';
$this->assertTrue($account2->save());
$account3 = new Account();
$account3->name = 'Dooble3';
$account3->owner = User::getByUsername('jimmy');
$this->assertTrue($account3->save());
$auditEvents = AuditEvent::getTailDistinctEventsByEventName('Item Viewed', Yii::app()->user->userModel, 5);
$this->assertEquals(0, count($auditEvents));
//Now create some audit entries for the Item Viewed event.
AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($account1), 'AccountsModule'), $account1);
AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($account2), 'AccountsModule'), $account2);
AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($account1), 'AccountsModule'), $account1);
//Switch users to add an audit event.
Yii::app()->user->userModel = User::getByUsername('jimmy');
AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($account3), 'AccountsModule'), $account3);
Yii::app()->user->userModel = User::getByUsername('super');
$auditEvents = AuditEvent::getTailDistinctEventsByEventName('Item Viewed', Yii::app()->user->userModel, 5);
$this->assertEquals(2, count($auditEvents));
}
示例2: getRecentlyViewedAuditEventsByUser
/**
* Given a user and a count, get a tail of recent audit events for that user limited by the count.
* @param User $user
*/
protected static function getRecentlyViewedAuditEventsByUser(User $user, $count)
{
assert('is_int($count)');
return AuditEvent::getTailDistinctEventsByEventName('Item Viewed', $user, $count);
}