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

	$urlPath = $uri->getPath();
	//todo: replace cycle with compiled regexp for all routes
	foreach(static::$routeTable as $routeRecord)
	{
		if(preg_match($routeRecord['REGEXP'], $urlPath, $matches))
		{
			$result = $routeRecord;
			//replace parameters variables with values
			foreach($result['PARAMETERS'] as $parameterName => &$parameterValue)
			{
				if(mb_strpos($parameterValue, '$') === 0)
				{
					$variableName = mb_substr($parameterValue, 1);
					if(isset($matches[$variableName]))
					{
						$parameterValue = $matches[$variableName];
					}
				}
			}
			unset($parameterValue);

			$uriQuery = $uri->getQuery();
			if (mb_strlen($uriQuery) > 0)
			{
				$uriQueryParams = static::parseQueryParams($uriQuery);
				foreach ($result['PARAMETERS'] as $parameterName => &$parameterValue)
				{
					if (mb_strpos($parameterValue, '$') === 0)
					{
						$variableName = mb_substr($parameterValue, 1);
						if (isset($uriQueryParams[$variableName]))
						{
							$parameterValue = $uriQueryParams[$variableName];
						}
					}
				}
				unset($parameterValue);
			}

			return $result;
		}
	}

	return false;
}