ILIAS  trunk Revision v12.0_alpha-399-g579a087ced2
Factory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use DateTimeImmutable;
24
29{
30 protected readonly \DateTimeZone $db_timezone;
31
32 public function __construct()
33 {
34 $this->db_timezone = new \DateTimeZone('UTC');
35 }
36
37 public function newsItem(array $row): NewsItem
38 {
39 return new NewsItem(
40 id: (int) $row['id'],
41 title: (string) $row['title'],
42 content: (string) $row['content'],
43 context_obj_id: (int) $row['context_obj_id'],
44 context_obj_type: (string) $row['context_obj_type'],
45 context_sub_obj_id: (int) $row['context_sub_obj_id'],
46 context_sub_obj_type: $row['context_sub_obj_type'] ?? null,
47 content_type: (string) $row['content_type'],
48 creation_date: new DateTimeImmutable($row['creation_date']), // currently date is stored in server tz, not UTC
49 update_date: new DateTimeImmutable($row['update_date']),
50 user_id: (int) $row['user_id'],
51 update_user_id: (int) $row['update_user_id'],
52 visibility: (string) $row['visibility'],
53 content_long: (string) $row['content_long'],
54 priority: (int) $row['priority'],
55 content_is_lang_var: (bool) $row['content_is_lang_var'],
56 content_text_is_lang_var: (bool) $row['content_text_is_lang_var'],
57 mob_id: (int) $row['mob_id'],
58 playtime: (string) $row['playtime'],
59 mob_cnt_play: (int) $row['mob_cnt_play'],
60 mob_cnt_download: (int) $row['mob_cnt_download'],
61 content_html: (bool) $row['content_html'],
62 context_ref_id: (int) ($row['ref_id'] ?? 0)
63 );
64 }
65}
Factory for creating News DTOs from database results (arrays)
Definition: Factory.php:29
readonly DateTimeZone $db_timezone
Definition: Factory.php:30
newsItem(array $row)
Definition: Factory.php:37
News Item DTO for transfer of news items.
Definition: NewsItem.php:29