本文整理汇总了PHP中Notification::newNotification方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::newNotification方法的具体用法?PHP Notification::newNotification怎么用?PHP Notification::newNotification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notification
的用法示例。
在下文中一共展示了Notification::newNotification方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNotification
public function testNotification()
{
$event = new WelcomeEvent("Welcome!", $this->player);
$this->notification = Notification::newNotification($this->player->getId(), Events::WELCOME, $event);
$this->assertEquals($event, $this->notification->getEvent());
$this->assertEquals(Events::WELCOME, $this->notification->getCategory());
$this->assertEquals($this->player->getId(), $this->notification->getReceiver()->getId());
$this->assertFalse($this->notification->isRead());
$this->notification->markAsRead();
$this->assertTrue($this->notification->isRead());
// Refresh the notification from the database
$this->notification = Notification::get($this->notification->getId());
$this->assertTrue($this->notification->isRead());
}
示例2: array
$blast = Player::newPlayer(180, "blast", null, "active", Player::S_ADMIN);
$kierra = Player::newPlayer(2229, "kierra", null, "active", Player::ADMIN, "", "", 174);
$mdskpr = Player::newPlayer(8312, "mdskpr");
$snake = Player::newPlayer(54497, "Snake12534");
$tw1sted = Player::newPlayer(9736, "tw1sted", null, "active", Player::DEVELOPER);
$brad = Player::newPlayer(3030, "brad", null, "active", Player::S_ADMIN, "", "I keep nagging about when this project will be done");
$constitution = Player::newPlayer(9972, "Constitution", null, "active", Player::S_ADMIN);
$themap = Player::newPlayer(57422, "the map", null, "active", Player::COP);
$oldSnake = Player::newPlayer(54498, "Snake12534");
$oldSnake->setOutdated(true);
$allPlayers = array($alezakos, $allejo, $ashvala, $autoreport, $blast, $kierra, $mdskpr, $snake, $tw1sted, $brad, $constitution, $themap);
echo " done!";
echo "\nSending notifications...";
foreach (Player::getPlayers() as $player) {
$event = new WelcomeEvent('Welcome to ' . Service::getParameter('bzion.site.name') . '!', $player);
Notification::newNotification($player->getId(), 'welcome', $event);
}
echo " done!";
echo "\nAdding deleted objects...";
Team::createTeam("Amphibians", $snake->getId(), "", "")->delete();
$snake->refresh();
Team::createTeam("Serpents", $snake->getId(), "", "")->delete();
$snake->refresh();
Page::addPage("Test", "<p>This is a deleted page</p>", $tw1sted->getId())->delete();
echo " done!";
echo "\nAdding teams...";
$olfm = Team::createTeam("OpenLeague FM?", $kierra->getId(), "", "");
$reptitles = Team::createTeam("Reptitles", $snake->getId(), "", "", "open");
$fflood = Team::createTeam("Formal Flood", $allejo->getId(), "", "");
$lweak = Team::createTeam("[LakeWeakness]", $mdskpr->getId(), "", "");
$gsepar = Team::createTeam("Good Separation", $tw1sted->getId(), "", "");
示例3: doNotify
/**
* Sends a notification to some players
*
* @param mixed $players A single player/ID or a player/ID list
* @param string $type The type of the event
* @param null|\Player|int $except A player who should not receive a notification
* @param \Player $except
*/
protected function doNotify($players, $type, $except = null)
{
Debug::log("Notifying about {$type}", array('players' => $players, 'except' => $except));
if ($except instanceof \Player) {
$except = $except->getId();
}
if (!is_array($players)) {
$players = array($players);
}
foreach ($players as $player) {
if ($player instanceof \Player) {
$player = $player->getId();
}
if ($player != $except) {
$notification = \Notification::newNotification($player, $type, $this);
\Service::getContainer()->get('event_dispatcher')->dispatch(Events::NOTIFICATION_NEW, new NewNotificationEvent($notification));
}
}
}