• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Entity/Url/UrlItem.php
  • Класс: Bitrix\Im\V2\Entity\Url\UrlItem
  • Вызов: UrlItem::__construct
public function __construct(?string $url = null, bool $withFetchMetadata = true)
{
	if (!empty($url))
	{
		$this->setUrl($url);
		if ($this->getUrl())
		{
			$metadata = static::$staticMetadataCache[$this->getUrl()] ?? null;
			if ($metadata === null && $withFetchMetadata)
			{
				try
				{
					$metadata = UrlPreview::getMetadataByUrl($this->getUrl(), true, false);
				}
				catch (\Exception $exception)
				{
					$metadata = false;
				}
				static::$staticMetadataCache[$this->getUrl()] = $metadata;
			}

			if ($metadata !== false && $metadata !== null)
			{
				$this->setMetadata($metadata);
			}
		}
	}
}