]> git.mxchange.org Git - friendica.git/blob - src/Navigation/Notifications/Factory/Notify.php
Merge pull request #10900 from annando/notify
[friendica.git] / src / Navigation / Notifications / Factory / Notify.php
1 <?php
2
3 namespace Friendica\Navigation\Notifications\Factory;
4
5 use Friendica\BaseFactory;
6 use Friendica\Capabilities\ICanCreateFromTableRow;
7 use Friendica\Content\Text\BBCode;
8 use GuzzleHttp\Psr7\Uri;
9
10 class Notify extends BaseFactory implements ICanCreateFromTableRow
11 {
12         public function createFromTableRow(array $row): \Friendica\Navigation\Notifications\Entity\Notify
13         {
14                 return new \Friendica\Navigation\Notifications\Entity\Notify(
15                         $row['type'],
16                         $row['name'],
17                         new Uri($row['url']),
18                         new Uri($row['photo']),
19                         new \DateTime($row['date'], new \DateTimeZone('UTC')),
20                         $row['uid'],
21                         new Uri($row['link']),
22                         $row['seen'],
23                         $row['verb'],
24                         $row['otype'],
25                         $row['name_cache'],
26                         $row['msg'],
27                         $row['msg_cache'],
28                         $row['iid'],
29                         $row['uri-id'],
30                         $row['parent'],
31                         $row['parent-uri-id'],
32                         $row['id']
33                 );
34         }
35
36         public function createFromParams($params, $itemlink = null, $item_id = null, $uri_id = null, $parent_id = null, $parent_uri_id = null): \Friendica\Navigation\Notifications\Entity\Notify
37         {
38                 return new \Friendica\Navigation\Notifications\Entity\Notify(
39                         $params['type'] ?? '',
40                         $params['source_name'] ?? '',
41                         new Uri($params['source_link'] ?? ''),
42                         new Uri($params['source_photo'] ?? ''),
43                         new \DateTime(),
44                         $params['uid'] ?? 0,
45                         new Uri($itemlink ?? ''),
46                         false,
47                         $params['verb'] ?? '',
48                         $params['otype'] ?? '',
49                         substr(strip_tags(BBCode::convertForUriId($uri_id, $params['source_name'])), 0, 255),
50                         null,
51                         null,
52                         $item_id,
53                         $uri_id,
54                         $parent_id,
55                         $parent_uri_id
56                 );
57         }
58 }