ProductImage::prepareFileStructure

  1. Bitrix24 API (v. 23.675.0)
  2. catalog
  3. ProductImage
  4. prepareFileStructure
  • Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/controller/productimage.php
  • Класс: BitrixCatalogControllerProductImage
  • Вызов: ProductImage::prepareFileStructure
private function prepareFileStructure(
	BaseImage $baseImage,
	CRestServer $restServer = null,
	array $selectedFields = null
): array
{
	$result = [];
	if (!$selectedFields)
	{
		$selectedFields = array_keys($this->getViewManager()->getView($this)->getFields());
	}

	foreach ($selectedFields as $name)
	{
		if ($name === 'ID')
		{
			$result[$name] = $baseImage->getField('ID');
		}
		if ($name === 'NAME')
		{
			$result[$name] = $baseImage->getField('FILE_NAME');
		}
		elseif ($name === 'DETAIL_URL')
		{
			$result[$name] = $baseImage->getSource();
		}
		elseif ($name === 'DOWNLOAD_URL')
		{
			$result[$name] =
				$restServer
					? CRestUtil::getDownloadUrl(['id' => $baseImage->getId()], $restServer)
					: $baseImage->getSource()
			;
		}
		elseif ($name === 'CREATE_TIME')
		{
			$result[$name] = $baseImage->getField('TIMESTAMP_X');
		}
		elseif ($name === 'PRODUCT_ID')
		{
			$result[$name] = $baseImage->getParent()->getId();
		}
		elseif ($name === 'TYPE')
		{
			$result[$name] = $baseImage->getCode();
		}
	}

	return $result;
}

Добавить комментарий