Add an ability to generate https routes

This commit is contained in:
Dmitriy Simushev 2014-08-20 13:00:03 +00:00
parent 82a3cb7dd5
commit e9f480e3ef

View File

@ -97,6 +97,26 @@ abstract class AbstractController implements RouterAwareInterface, Authenticatio
return $this->getRouter()->generate($route, $parameters, $referenceType); return $this->getRouter()->generate($route, $parameters, $referenceType);
} }
/**
* Generates an HTTPS URL from the given parameters.
*
* @param string $route The name of the route.
* @param mixed $parameters An array of parameters.
*
* @return string The generated URL.
*/
public function generateSecureUrl($route, $parameters = array())
{
$context = $this->getRouter()->getContext();
return 'https://' . $context->getHost()
. $this->getRouter()->generate(
$route,
$parameters,
UrlGeneratorInterface::ABSOLUTE_PATH
);
}
/** /**
* Returns a RedirectResponse to the given URL. * Returns a RedirectResponse to the given URL.
* *