• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/lib/component/tools.php
  • Класс: BitrixIblockComponentTools
  • Вызов: Tools::process404
static function process404($message = "", $defineConstant = true, $setStatus = true, $showPage = false, $pageFile = "")
{
	/** @global CMain $APPLICATION */
	global $APPLICATION;

	$message = (string)$message;
	$pageFile = (string)$pageFile;
	if ($message !== '')
	{
		$APPLICATION->includeComponent(
			'bitrix:system.show_message',
			'.default',
			[
				'MESSAGE' => $message,
				'STYLE' => 'errortext',
			],
			null,
			[
				'HIDE_ICONS' => 'Y',
			]
		);
	}

	if ($defineConstant && !defined('ERROR_404'))
	{
		define('ERROR_404', 'Y');
	}

	if ($setStatus)
	{
		CHTTP::setStatus('404 Not Found');
	}

	if ($showPage)
	{
		if ($APPLICATION->RestartWorkarea())
		{
			if (!defined('BX_URLREWRITE'))
			{
				define('BX_URLREWRITE', true);
			}
			MainCompositeEngine::setEnable(false);
			if ($pageFile !== '')
			{
				require MainApplication::getDocumentRoot() . rel2abs('/', '/' . $pageFile);
			}
			else
			{
				require MainApplication::getDocumentRoot() . '/404.php';
			}
			die();
		}
	}
}