[Routing] deprecate the old url generator reference type values
This commit is contained in:
parent
a65b489d2b
commit
912fc4de8f
@ -39,9 +39,9 @@ class Controller extends ContainerAware
|
||||
/**
|
||||
* Generates a URL from the given parameters.
|
||||
*
|
||||
* @param string $route The name of the route
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param bool|string $referenceType The type of reference (one of the constants in UrlGeneratorInterface)
|
||||
* @param string $route The name of the route
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param int $referenceType The type of reference (one of the constants in UrlGeneratorInterface)
|
||||
*
|
||||
* @return string The generated URL
|
||||
*
|
||||
|
@ -36,9 +36,9 @@ class RouterHelper extends Helper
|
||||
/**
|
||||
* Generates a URL from the given parameters.
|
||||
*
|
||||
* @param string $name The name of the route
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param bool|string $referenceType The type of reference (one of the constants in UrlGeneratorInterface)
|
||||
* @param string $name The name of the route
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param int $referenceType The type of reference (one of the constants in UrlGeneratorInterface)
|
||||
*
|
||||
* @return string The generated URL
|
||||
*
|
||||
|
@ -143,6 +143,20 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
*/
|
||||
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array())
|
||||
{
|
||||
if (is_bool($referenceType) || is_string($referenceType)) {
|
||||
@trigger_error('The hardcoded value you are using for the $referenceType argument of the '.__CLASS__.'::generate method is deprecated since version 2.8 and will not be supported anymore in 3.0. Use the constants defined in the UrlGeneratorInterface instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (true === $referenceType) {
|
||||
$referenceType = self::ABSOLUTE_URL;
|
||||
} elseif (false === $referenceType) {
|
||||
$referenceType = self::ABSOLUTE_PATH;
|
||||
} elseif ('relative' === $referenceType) {
|
||||
$referenceType = self::RELATIVE_PATH;
|
||||
} elseif ('network' === $referenceType) {
|
||||
$referenceType = self::NETWORK_PATH;
|
||||
}
|
||||
}
|
||||
|
||||
$variables = array_flip($variables);
|
||||
$mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters);
|
||||
|
||||
|
@ -34,25 +34,25 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
|
||||
/**
|
||||
* Generates an absolute URL, e.g. "http://example.com/dir/file".
|
||||
*/
|
||||
const ABSOLUTE_URL = true;
|
||||
const ABSOLUTE_URL = 0;
|
||||
|
||||
/**
|
||||
* Generates an absolute path, e.g. "/dir/file".
|
||||
*/
|
||||
const ABSOLUTE_PATH = false;
|
||||
const ABSOLUTE_PATH = 1;
|
||||
|
||||
/**
|
||||
* Generates a relative path based on the current request path, e.g. "../parent-file".
|
||||
*
|
||||
* @see UrlGenerator::getRelativePath()
|
||||
*/
|
||||
const RELATIVE_PATH = 'relative';
|
||||
const RELATIVE_PATH = 2;
|
||||
|
||||
/**
|
||||
* Generates a network path, e.g. "//example.com/dir/file".
|
||||
* Such reference reuses the current scheme but specifies the host.
|
||||
*/
|
||||
const NETWORK_PATH = 'network';
|
||||
const NETWORK_PATH = 3;
|
||||
|
||||
/**
|
||||
* Generates a URL or path for a specific route based on the given parameters.
|
||||
@ -69,9 +69,9 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
|
||||
*
|
||||
* If there is no route with the given name, the generator must throw the RouteNotFoundException.
|
||||
*
|
||||
* @param string $name The name of the route
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param bool|string $referenceType The type of reference to be generated (one of the constants)
|
||||
* @param string $name The name of the route
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param int $referenceType The type of reference to be generated (one of the constants)
|
||||
*
|
||||
* @return string The generated URL
|
||||
*
|
||||
|
@ -86,7 +86,7 @@ class LogoutUrlGenerator
|
||||
* Generates the logout URL for the firewall.
|
||||
*
|
||||
* @param string|null $key The firewall key or null to use the current firewall key
|
||||
* @param bool|string $referenceType The type of reference (one of the constants in UrlGeneratorInterface)
|
||||
* @param int $referenceType The type of reference (one of the constants in UrlGeneratorInterface)
|
||||
*
|
||||
* @return string The logout URL
|
||||
*
|
||||
|
Reference in New Issue
Block a user