• Модуль: documentgenerator
  • Путь к файлу: ~/bitrix/modules/documentgenerator/lib/template.php
  • Класс: BitrixDocumentGeneratorTemplate
  • Вызов: Template::getFields
public function getFields(): array
{
	if($this->fields === null)
	{
		$this->fields = [];
		$this->fields[static::DOCUMENT_PROVIDER_PLACEHOLDER] = [
			'PROVIDER' => DataProviderDocument::class,
			'TEMPLATE_ID' => $this->ID,
			'REQUIRED' => 'Y',
		];
		$placeholders = [];
		$body = $this->getBody();
		if($body)
		{
			$allFields = $fieldNames = [];
			$placeholders = $body->getFieldNames();
			foreach($placeholders as $placeholder)
			{
				$fieldNames[$placeholder] = $placeholder;
				$fieldNames += static::getLevelsFromPlaceholder($placeholder);
			}
			if(!empty($fieldNames))
			{
				$getListResult = FieldTable::getList(['filter' => ['=PLACEHOLDER' => $fieldNames]]);
				while($field = $getListResult->fetch())
				{
					$allFields[$field['PLACEHOLDER']][] = $field;
				}
				foreach($allFields as $placeholder => $placeholderFields)
				{
					$this->fields[$placeholder] = $this->getPriorityField($placeholderFields);
				}
			}
		}
		if($this->sourceType)
		{
			$this->fields[static::MAIN_PROVIDER_PLACEHOLDER] = [
				'PROVIDER' => $this->sourceType,
				'TEMPLATE_ID' => $this->ID,
				'REQUIRED' => 'Y',
			];
			$this->fields[static::DOCUMENT_PROVIDER_PLACEHOLDER]['OPTIONS'] = [
				'PROVIDER' => $this->sourceType,
			];
		}
		$emptyPlaceholders = array_diff($placeholders, array_keys($this->fields));
		if(!empty($emptyPlaceholders))
		{
			$this->fields = array_merge($this->fields, DataProviderManager::getInstance()->getDefaultTemplateFields($this->sourceType, $emptyPlaceholders, ['REGION' => $this->REGION], true, true));
		}
	}

	return $this->fields;
}