Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
blog.php
1<?php
3
4use \Bitrix\Socialnetwork\Livefeed\BlogPost;
5
6class Blog 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 $post = \CBlogPost::getByID($sourceId);
21 if (BlogPost::canRead(['POST' => $post]))
22 {
23 $params = [];
24 $blocks = [[
25 'type' => 'header',
26 'content' => $post['TITLE']
27 ]];
28 if (\Bitrix\Main\Loader::includeModule('disk'))
29 {
30 $params = [
31 'files' => self::getDiskFiles(
32 $sourceId,
33 \Bitrix\Disk\Uf\BlogPostConnector::class,
34 'blog'
35 )
36 ];
37 }
38 $blocks = array_merge(
39 $blocks,
40 Parser::textToBlocks($post['DETAIL_TEXT'], $params)
41 );
42 return [
43 'TITLE' => \truncateText($post['TITLE'], self::TITLE_LENGTH),
44 'BLOCKS' => $blocks
45 ];
46 }
47 }
48
49 return null;
50 }
51}
static getData(int $sourceId)
Definition blog.php:13
static getDiskFiles(int $sourceId, string $entityType, string $module)
Definition entity.php:18
static textToBlocks(string $text, array $params=[])
Definition parser.php:212