- Модуль: documentgenerator
- Путь к файлу: ~/bitrix/modules/documentgenerator/lib/body/docx.php
- Класс: BitrixDocumentGeneratorBodyDocx
- Вызов: Docx::parseRelationships
protected function parseRelationships(string $documentPath): array
{
$relationshipPath = $this->getRelationshipPath($documentPath);
$relationshipsContent = $this->zip->getFromName($relationshipPath);
$relationshipsData = [];
$relationshipsDocument = new DOMDocument();
if(!empty($relationshipsContent))
{
try
{
$relationshipsDocument->loadXML($relationshipsContent);
}
catch (ValueError $emptyArgumentError)
{
Application::getInstance()->getExceptionHandler()->writeToLog($emptyArgumentError);
}
foreach($relationshipsDocument->getElementsByTagName('Relationship') as $relationship)
{
$id = $relationship->attributes->getNamedItem('Id');
if($id)
{
$id = $id->value;
}
$target = $relationship->attributes->getNamedItem('Target');
if($target)
{
$target = $target->value;
}
$type = $relationship->attributes->getNamedItem('Type');
if($type)
{
$type = $type->value;
}
if($id && $target && $type)
{
$relationshipsData[$type][$id] = [
'type' => $type,
'id' => $id,
'target' => $target,
'node' => $relationship,
];
}
}
}
return [
'data' => $relationshipsData,
'document' => $relationshipsDocument,
'path' => $relationshipPath,
];
}