UploaderError::__construct

  1. Bitrix24 API (v. 23.675.0)
  2. ui
  3. UploaderError
  4. __construct
  • Модуль: ui
  • Путь к файлу: ~/bitrix/modules/ui/lib/FileUploader/UploaderError.php
  • Класс: BitrixUIFileUploaderUploaderError
  • Вызов: UploaderError::__construct
public function __construct(string $code, ...$args)
{
	$message = isset($args[0]) && is_string($args[0]) ? $args[0] : null;
	$description = isset($args[1]) && is_string($args[1]) ? $args[1] : null;
	$lastIndex = count($args) - 1;
	$customData = isset($args[$lastIndex]) && is_array($args[$lastIndex]) ? $args[$lastIndex] : [];

	$replacements = [];
	foreach ($customData as $key => $value)
	{
		$replacements["#{$key}#"] = $value;
	}

	if (isset(self::$systemErrors[$code]))
	{
		$message = self::$systemErrors[$code];
		foreach ($replacements as $search => $repl)
		{
			$message = str_replace($search, $repl, $message);
		}

		$this->setSystem(true);
		$description = '';
	}

	if (!is_string($message))
	{
		$message = Loc::getMessage("UPLOADER_{$code}", $replacements);
	}

	if (is_string($message) && mb_strlen($message) > 0 && !is_string($description))
	{
		$description = Loc::getMessage("UPLOADER_{$code}_DESC", $replacements);
	}

	if (!is_string($message) || mb_strlen($message) === 0)
	{
		$message = $code;
	}

	parent::__construct($message, $code, $customData);

	if (is_string($description))
	{
		$this->setDescription($description);
	}
}

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