- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/Service/Timeline/Item/Activity/ConfigurableRestApp.php
- Класс: Bitrix\Crm\Service\Timeline\Item\Activity\ConfigurableRestApp
- Вызов: ConfigurableRestApp::createContentBlock
private function createContentBlock(?ContentBlockDto $contentBlockDto): ?ContentBlock
{
if (!$this->isValidDto($contentBlockDto))
{
return null;
}
$properties = $contentBlockDto->properties ?? new \stdClass();
switch ($contentBlockDto->type)
{
case ContentBlockDto::TYPE_TEXT:
/** @var $properties TextDto */
return (new ContentBlock\Text())
->setValue($properties->value)
->setIsMultiline($properties->multiline)
->setTitle($properties->title)
->setIsBold($properties->bold)
->setFontSize($properties->size)
->setColor($properties->color)
->setScope($properties->scope)
;
case ContentBlockDto::TYPE_LARGE_TEXT:
return (new ContentBlock\EditableDescription())
->setText($properties->value)
->setEditable(false)
->setHeight(ContentBlock\EditableDescription::HEIGHT_LONG)
;
case ContentBlockDto::TYPE_LINK:
/** @var $properties LinkDto */
return (new ContentBlock\Link())
->setValue($properties->text)
->setIsBold($properties->bold)
->setAction($this->createAction($properties->action))
->setScope($properties->scope)
;
case ContentBlockDto::TYPE_DEADLINE:
/** @var $properties DeadlineDto */
if ($this->getDeadline())
{
$readonly = !$this->isScheduled() || ($properties->readonly ?? false);
return (new ContentBlock\EditableDate())
->setStyle(ContentBlock\EditableDate::STYLE_PILL)
->setDate($this->getDeadline())
->setAction($readonly ? null : $this->getChangeDeadlineAction())
->setBackgroundColor($readonly ? null : ContentBlock\EditableDate::BACKGROUND_COLOR_WARNING)
->setScope($properties->scope)
;
}
return null;
case ContentBlockDto::TYPE_WITH_TITLE:
/** @var $properties WithTitleDto */
if (!$properties->block || !$this->isValidChildContentBlock($properties->block))
{
return null;
}
$childBlock = $this->createContentBlock($properties->block);
if (!$childBlock)
{
return null;
}
return (new ContentBlock\ContentBlockWithTitle())
->setTitle($properties->title)
->setWordWrap(true)
->setInline($properties->inline)
->setContentBlock($childBlock)
->setScope($properties->scope)
;
case ContentBlockDto::TYPE_LINE_OF_BLOCKS:
/** @var $properties LineOfBlocksDto */
if (!is_array($properties->blocks))
{
return null;
}
$blocks = [];
foreach ($properties->blocks as $blockId => $blockDto)
{
if (!$this->isValidChildContentBlock($blockDto))
{
continue;
}
$block = $this->createContentBlock($blockDto);
if ($block)
{
$blocks[(string)$blockId] = $block;
}
}
if (empty($blocks))
{
return null;
}
return (new ContentBlock\LineOfTextBlocks())
->setScope($properties->scope)
->setContentBlocks($blocks)
;
}
return null;
}