core-bundle/src/Resources/contao/models/PageModel.php
public function getFrontendUrl($strParams=null, $strForceLang=null)
	{
		if ($strForceLang !== null)
		{
			@trigger_error('Using PageModel::getFrontendUrl() with $strForceLang has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
		}

		$this->loadDetails();

		$objUrlGenerator = System::getContainer()->get('contao.routing.url_generator');

		$strUrl = $objUrlGenerator->generate
		(
			($this->alias ?: $this->id) . $strParams,
			array
			(
				'_locale' => ($strForceLang ?: $this->rootLanguage),
				'_domain' => $this->domain,
				'_ssl' => (bool) $this->rootUseSSL,
			)
		);

		// Make the URL relative to the base path
		if (0 === strncmp($strUrl, '/', 1))
		{
			$strUrl = substr($strUrl, \strlen(Environment::get('path')) + 1);
		}

		$strUrl = $this->applyLegacyLogic($strUrl, $strParams);

		return $strUrl;
	}
public function getFrontendUrl($strParams=null, $strForceLang=null)
	{
		if ($strForceLang !== null)
		{
			@trigger_error('Using PageModel::getFrontendUrl() with $strForceLang has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
		}

		$this->loadDetails();

		$objUrlGenerator = System::getContainer()->get('contao.routing.url_generator');

		$strUrl = $objUrlGenerator->generate
		(
			($this->alias ?: $this->id) . $strParams,
			array
			(
				'_locale' => ($strForceLang ?: $this->rootLanguage),
				'_domain' => $this->domain,
				'_ssl' => (bool) $this->rootUseSSL,
			)
		);

		// Make the URL relative to the base path
		if (0 === strncmp($strUrl, '/', 1))
		{
			$strUrl = substr($strUrl, \strlen(Environment::get('path')) + 1);
		}

		$strUrl = $this->applyLegacyLogic($strUrl, $strParams);

		return $strUrl;
	}
Generate a front end URL

@param string $strParams    An optional string of URL parameters
@param string $strForceLang Force a certain language

@return string An URL that can be used in the front end