• Модуль: translate
  • Путь к файлу: ~/bitrix/modules/translate/lib/settings.php
  • Класс: BitrixTranslateSettings
  • Вызов: Settings::save
public function save(): bool
{
	$content = '';
	if ($this->count() > 0)
	{
		$content = var_export($this->options, true);
		$content = preg_replace("/^[ ]{6}(.*)/m", "ttt$1", $content);
		$content = preg_replace("/^[ ]{4}(.*)/m", "tt$1", $content);
		$content = preg_replace("/^[ ]{2}(.*)/m", "t$1", $content);
		$content = str_replace(["rn", "r"], ["n", ''], $content);
	}

	set_error_handler(
		function ($severity, $message, $file, $line)
		{
			throw new ErrorException($message, $severity, $severity, $file, $line);
		}
	);

	try
	{
		if ($content <> '')
		{
			if (parent::putContents("<". "?phpnreturn ". $content. "n?". '>') === false)
			{
				$filePath = $this->getPath();
				throw new MainIOIoException("Couldn't write option file '{$filePath}'");
			}
		}
		elseif ($this->isExists())
		{
			$this->markWritable();
			$this->delete();
		}
	}
	catch (ErrorException $exception)
	{
		restore_error_handler();
		throw new MainIOIoException($exception->getMessage());
	}

	restore_error_handler();

	return true;
}