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/NotificationGroup.php

41 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2018-10-16 16:28:42 +00:00
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once 'Notification.php';
class NotificationGroup
{
protected $notifications;
protected $realCount;
public function __construct(array $notifications, $count)
{
$this->notifications = $notifications;
$this->realCount = $count;
}
public function message() {
if($this->realCount == 1) {
return $this->notifications[0]->messageForNotification($this->notifications[0]);
}
return $this->notifications[0]->messageForNotifications($this->notifications, $this->realCount);
}
public function __get($attribute)
{
if($attribute == 'unread') {
foreach ($this->notifications as $notification) {
if($notification->unread)
return TRUE;
}
RETURN FALSE;
}
2018-10-17 14:27:56 +00:00
return !empty($this->notifications) ? $this->notifications[0]->{$attribute} : null;
2018-10-16 16:28:42 +00:00
}
public function __call($name, $arguments)
{
return call_user_func_array([$this->notifications[0], $name], $arguments);
}
}