1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Apps\Model\Front\Profile; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use Apps\ActiveRecord\UserNotification; |
7
|
|
|
use Ffcms\Core\App; |
8
|
|
|
use Ffcms\Core\Arch\Model; |
9
|
|
|
use Ffcms\Core\Helper\Date; |
10
|
|
|
use Ffcms\Core\Helper\Serialize; |
11
|
|
|
use Ffcms\Core\Helper\Type\Str; |
12
|
|
|
use Ffcms\Core\Helper\Url; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class EntityNotificationsList. Build notification messages from active record object |
16
|
|
|
* @package Apps\Model\Front\Profile |
17
|
|
|
*/ |
18
|
|
|
class EntityNotificationsList extends Model |
19
|
|
|
{ |
20
|
|
|
public $items; |
21
|
|
|
|
22
|
|
|
/** @var UserNotification */ |
23
|
|
|
private $_records; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* EntityNotificationsList constructor. Pass records object inside. |
27
|
|
|
* @param bool $records |
28
|
|
|
*/ |
29
|
|
|
public function __construct($records) |
30
|
|
|
{ |
31
|
|
|
$this->_records = $records; |
|
|
|
|
32
|
|
|
parent::__construct(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Build notification list as array |
37
|
|
|
*/ |
38
|
|
|
public function make() |
39
|
|
|
{ |
40
|
|
|
// check if records is not empty |
41
|
|
|
if ($this->_records === null) { |
42
|
|
|
return; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
// list records and build response |
46
|
|
|
foreach ($this->_records as $record) { |
|
|
|
|
47
|
|
|
/** @var UserNotification $record */ |
48
|
|
|
$vars = null; |
49
|
|
|
if (!Str::likeEmpty($record->vars)) { |
50
|
|
|
$vars = Serialize::decode($record->vars); |
51
|
|
|
} |
52
|
|
|
if (!$vars !== null && isset($vars['snippet'])) { |
53
|
|
|
$vars['snippet'] = Url::standaloneLink($vars['snippet'], $record->uri, App::$Request->getLanguage()); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$text = App::$Translate->get('Profile', $record->msg, $vars); |
|
|
|
|
57
|
|
|
|
58
|
|
|
$this->items[] = [ |
59
|
|
|
'text' => $text, |
60
|
|
|
'date' => Date::humanize($record->created_at) |
61
|
|
|
]; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
} |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..