Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
blogcomment.php
1<?php
3
4use \Bitrix\Socialnetwork\Livefeed\BlogPost;
5
6class BlogComment extends Entity
7{
13 public static function getData(int $sourceId): ?array
14 {
15 if (
16 \Bitrix\Main\Loader::includeModule('blog') &&
17 \Bitrix\Main\Loader::includeModule('socialnetwork')
18 )
19 {
20 $comment = \CBlogComment::getByID($sourceId);
21 if (!$comment || $comment['PUBLISH_STATUS'] != BLOG_PUBLISH_STATUS_PUBLISH)
22 {
23 return null;
24 }
25 $post = \CBlogPost::getByID($comment['POST_ID']);
26 if (BlogPost::canRead(['POST' => $post]))
27 {
28 $params = [];
29 $blocks = [[
30 'type' => 'header',
31 'content' => $post['TITLE']
32 ]];
33 if (\Bitrix\Main\Loader::includeModule('disk'))
34 {
35 $params = [
36 'files' => self::getDiskFiles(
37 $sourceId,
38 \Bitrix\Disk\Uf\BlogPostCommentConnector::class,
39 'blog'
40 )
41 ];
42 }
43 $blocks = array_merge(
44 $blocks,
45 Parser::textToBlocks($comment['POST_TEXT'], $params)
46 );
47 return [
48 'TITLE' => \truncateText($post['TITLE'], self::TITLE_LENGTH),
49 'BLOCKS' => $blocks
50 ];
51 }
52 }
53
54 return null;
55 }
56}
static getDiskFiles(int $sourceId, string $entityType, string $module)
Definition entity.php:18
static textToBlocks(string $text, array $params=[])
Definition parser.php:212