• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/urlpreview/router.php
  • Класс: BitrixMainUrlPreviewRouter
  • Вызов: Router::setRouteHandler
static function setRouteHandler($route, $handlerModule, $handlerClass, array $handlerParameters)
{
	static::init();

	if(!is_string($route) || $route == '')
		throw new ArgumentException('Route could not be empty', '$route');
	if(!is_string($handlerModule) || $handlerModule == '')
		throw new ArgumentException('Handler module could not be empty', '$handler');
	if(!is_string($handlerClass) || $handlerClass == '')
		throw new ArgumentException('Handler class could not be empty', '$handler');

	$newRoute = true;
	if(isset(static::$routeTable[$route]))
	{
		if (   $handlerModule === static::$routeTable[$route]['MODULE']
			&& $handlerClass === static::$routeTable[$route]['CLASS']
			&& $handlerParameters == static::$routeTable[$route]['PARAMETERS']
		)
		{
			return;
		}
		$newRoute = false;
	}

	$allowSlashes = ($handlerParameters['allowSlashes'] ?? 'N') === 'Y';
	static::$routeTable[$route]['ROUTE'] = $route;
	static::$routeTable[$route]['REGEXP'] = static::convertRouteToRegexp($route, $allowSlashes);
	static::$routeTable[$route]['MODULE'] = $handlerModule;
	static::$routeTable[$route]['CLASS'] = $handlerClass;
	static::$routeTable[$route]['PARAMETERS'] = $handlerParameters;

	static::persistRoute($route, $newRoute);
}