Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/application/models/notifications/PostLikeNotification.php
2018-10-16 18:28:42 +02:00

46 lines
1.4 KiB
PHP

<?php
namespace Notification\Users;
use Notification;
require_once 'Notification.php';
class PostLikeNotification extends \Notification
{
public function __construct(array $data)
{
$data['type'] = 'users.likedPost';
parent::__construct($data);
}
public function getNotificationLink()
{
return '/user/' . $this->recipient->getUsername() . '/post/' . $this->parameters;
}
public function getNotificationImage()
{
return $this->sender->getProfilePicture();
}
public function messageForNotification(Notification $notification)
{
return ['line' => 'users.likedPost.single', 'attributes' => [$this->sender->getName()]];
}
public function messageForNotifications(array $notifications, $realCount = 0)
{
if ($realCount === 0) {
$realCount = count($notifications);
}
if ($realCount < 5) {
$names = $this->manyNames($notifications);
return ['line' => 'users.likedPost.multiple', 'attributes' => [$names]];
} else {
$names = $this->manyNamesCutoff($notifications, $realCount);
return ['line' => 'users.likedPost.many', 'attributes' => [$names]];
}
}
}