• Модуль: forum
  • Путь к файлу: ~/bitrix/modules/forum/lib/comments/baseobject.php
  • Класс: BitrixForumCommentsBaseObject
  • Вызов: BaseObject::getEntity
public function getEntity()
{
	if ($this->entity instanceof Entity)
		return $this->entity;

	if (!is_array($this->entity))
		throw new ArgumentTypeException("entity");

	$id = $this->entity;
	$protoEntity = Entity::getEntityByType($id["type"]);
	if (is_null($protoEntity))
	{
		$protoEntity = Entity::getEntityByType("default");
		if (!array_key_exists('xml_id', $id) || empty($id["xml_id"]))
			$id['xml_id'] = mb_strtoupper($id["type"]."_".$id['id']);
	}
	elseif (!array_key_exists('xml_id', $id) || empty($id["xml_id"]))
		$id['xml_id'] = $protoEntity["xmlIdPrefix"]."_".$id['id'];
	if (!Loader::includeModule($protoEntity["moduleId"]))
		throw new SystemException("Module {$protoEntity["moduleId"]} is not included.");

	$this->entity = new $protoEntity["className"]($id, $this->getForum());
	if (! $this->entity instanceof Entity)
		throw new SystemException("Entity Class does not descended from \Bitrix\Forum\Comments\Entity.");

	return $this->entity;
}