• Модуль: documentgenerator
  • Путь к файлу: ~/bitrix/modules/documentgenerator/lib/body/docx.php
  • Класс: BitrixDocumentGeneratorBodyDocx
  • Вызов: Docx::fillInnerDocuments
protected function fillInnerDocuments(): void
{
	$xmlClassName = $this->getXmlClassName();
	$this->innerDocuments[static::PATH_DOCUMENT] = [
		'relationships' => $this->parseRelationships(static::PATH_DOCUMENT),
		'document' => (new $xmlClassName($this->zip->getFromName(static::PATH_DOCUMENT)))->setValues($this->values)->setFields($this->fields),
	];
	if(isset($this->innerDocuments[static::PATH_DOCUMENT]['relationships']['data'][static::REL_TYPE_FOOTER]))
	{
		foreach($this->innerDocuments[static::PATH_DOCUMENT]['relationships']['data'][static::REL_TYPE_FOOTER] as $relationship)
		{
			$documentPath = 'word/'.$relationship['target'];
			$this->innerDocuments[$documentPath] = [
				'relationships' => $this->parseRelationships($documentPath),
				'document' => (new $xmlClassName($this->zip->getFromName($documentPath)))->setValues($this->values)->setFields($this->fields),
			];
		}
	}
	if(isset($this->innerDocuments[static::PATH_DOCUMENT]['relationships']['data'][static::REL_TYPE_HEADER]))
	{
		foreach($this->innerDocuments[static::PATH_DOCUMENT]['relationships']['data'][static::REL_TYPE_HEADER] as $relationship)
		{
			$documentPath = 'word/'.$relationship['target'];
			$this->innerDocuments[$documentPath] = [
				'relationships' => $this->parseRelationships($documentPath),
				'document' => (new $xmlClassName($this->zip->getFromName($documentPath)))->setValues($this->values)->setFields($this->fields),
			];
		}
	}
	// take only the first numbering.xml - we will add only
	if(isset($this->innerDocuments[static::PATH_DOCUMENT]['relationships']['data'][static::REL_TYPE_NUMBERING]))
	{
		foreach($this->innerDocuments[static::PATH_DOCUMENT]['relationships']['data'][static::REL_TYPE_NUMBERING] as $relationship)
		{
			$this->numbering['documentPath'] = 'word/'.$relationship['target'];
			break;
		}
	}
	$this->contentTypesDocument = new DOMDocument();
	try
	{
		$this->contentTypesDocument->loadXML($this->zip->getFromName(static::PATH_CONTENT_TYPES));
	}
	catch (ValueError $emptyArgumentError)
	{
		Application::getInstance()->getExceptionHandler()->writeToLog($emptyArgumentError);
	}
}