updated-packages
This commit is contained in:
65
vendor/symfony/routing/Generator/CompiledUrlGenerator.php
vendored
Normal file
65
vendor/symfony/routing/Generator/CompiledUrlGenerator.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Generator;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* Generates URLs based on rules dumped by CompiledUrlGeneratorDumper.
|
||||
*/
|
||||
class CompiledUrlGenerator extends UrlGenerator
|
||||
{
|
||||
private $compiledRoutes = [];
|
||||
private $defaultLocale;
|
||||
|
||||
public function __construct(array $compiledRoutes, RequestContext $context, LoggerInterface $logger = null, string $defaultLocale = null)
|
||||
{
|
||||
$this->compiledRoutes = $compiledRoutes;
|
||||
$this->context = $context;
|
||||
$this->logger = $logger;
|
||||
$this->defaultLocale = $defaultLocale;
|
||||
}
|
||||
|
||||
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
|
||||
{
|
||||
$locale = $parameters['_locale']
|
||||
?? $this->context->getParameter('_locale')
|
||||
?: $this->defaultLocale;
|
||||
|
||||
if (null !== $locale) {
|
||||
do {
|
||||
if (($this->compiledRoutes[$name.'.'.$locale][1]['_canonical_route'] ?? null) === $name) {
|
||||
$name .= '.'.$locale;
|
||||
break;
|
||||
}
|
||||
} while (false !== $locale = strstr($locale, '_', true));
|
||||
}
|
||||
|
||||
if (!isset($this->compiledRoutes[$name])) {
|
||||
throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
|
||||
}
|
||||
|
||||
[$variables, $defaults, $requirements, $tokens, $hostTokens, $requiredSchemes] = $this->compiledRoutes[$name];
|
||||
|
||||
if (isset($defaults['_canonical_route']) && isset($defaults['_locale'])) {
|
||||
if (!\in_array('_locale', $variables, true)) {
|
||||
unset($parameters['_locale']);
|
||||
} elseif (!isset($parameters['_locale'])) {
|
||||
$parameters['_locale'] = $defaults['_locale'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
|
||||
}
|
||||
}
|
@@ -20,7 +20,7 @@ namespace Symfony\Component\Routing\Generator;
|
||||
* The possible configurations and use-cases:
|
||||
* - setStrictRequirements(true): Throw an exception for mismatching requirements. This
|
||||
* is mostly useful in development environment.
|
||||
* - setStrictRequirements(false): Don't throw an exception but return null as URL for
|
||||
* - setStrictRequirements(false): Don't throw an exception but return an empty string as URL for
|
||||
* mismatching requirements and log the problem. Useful when you cannot control all
|
||||
* params because they come from third party libs but don't want to have a 404 in
|
||||
* production environment. It should log the mismatch so one can review it.
|
||||
|
73
vendor/symfony/routing/Generator/Dumper/CompiledUrlGeneratorDumper.php
vendored
Normal file
73
vendor/symfony/routing/Generator/Dumper/CompiledUrlGeneratorDumper.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Generator\Dumper;
|
||||
|
||||
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper;
|
||||
|
||||
/**
|
||||
* CompiledUrlGeneratorDumper creates a PHP array to be used with CompiledUrlGenerator.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Tobias Schultze <http://tobion.de>
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class CompiledUrlGeneratorDumper extends GeneratorDumper
|
||||
{
|
||||
public function getCompiledRoutes(): array
|
||||
{
|
||||
$compiledRoutes = [];
|
||||
foreach ($this->getRoutes()->all() as $name => $route) {
|
||||
$compiledRoute = $route->compile();
|
||||
|
||||
$compiledRoutes[$name] = [
|
||||
$compiledRoute->getVariables(),
|
||||
$route->getDefaults(),
|
||||
$route->getRequirements(),
|
||||
$compiledRoute->getTokens(),
|
||||
$compiledRoute->getHostTokens(),
|
||||
$route->getSchemes(),
|
||||
];
|
||||
}
|
||||
|
||||
return $compiledRoutes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dump(array $options = [])
|
||||
{
|
||||
return <<<EOF
|
||||
<?php
|
||||
|
||||
// This file has been auto-generated by the Symfony Routing Component.
|
||||
|
||||
return [{$this->generateDeclaredRoutes()}
|
||||
];
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates PHP code representing an array of defined routes
|
||||
* together with the routes properties (e.g. requirements).
|
||||
*/
|
||||
private function generateDeclaredRoutes(): string
|
||||
{
|
||||
$routes = '';
|
||||
foreach ($this->getCompiledRoutes() as $name => $properties) {
|
||||
$routes .= sprintf("\n '%s' => %s,", $name, CompiledUrlMatcherDumper::export($properties));
|
||||
}
|
||||
|
||||
return $routes;
|
||||
}
|
||||
}
|
@@ -24,11 +24,9 @@ interface GeneratorDumperInterface
|
||||
* Dumps a set of routes to a string representation of executable code
|
||||
* that can then be used to generate a URL of such a route.
|
||||
*
|
||||
* @param array $options An array of options
|
||||
*
|
||||
* @return string Executable code
|
||||
*/
|
||||
public function dump(array $options = array());
|
||||
public function dump(array $options = []);
|
||||
|
||||
/**
|
||||
* Gets the routes to dump.
|
||||
|
@@ -11,13 +11,17 @@
|
||||
|
||||
namespace Symfony\Component\Routing\Generator\Dumper;
|
||||
|
||||
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
|
||||
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "CompiledUrlGeneratorDumper" instead.', PhpGeneratorDumper::class), \E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper;
|
||||
|
||||
/**
|
||||
* PhpGeneratorDumper creates a PHP class able to generate URLs for a given set of routes.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Tobias Schultze <http://tobion.de>
|
||||
*
|
||||
* @deprecated since Symfony 4.3, use CompiledUrlGeneratorDumper instead.
|
||||
*/
|
||||
class PhpGeneratorDumper extends GeneratorDumper
|
||||
{
|
||||
@@ -33,12 +37,12 @@ class PhpGeneratorDumper extends GeneratorDumper
|
||||
*
|
||||
* @return string A PHP class representing the generator class
|
||||
*/
|
||||
public function dump(array $options = array())
|
||||
public function dump(array $options = [])
|
||||
{
|
||||
$options = array_merge(array(
|
||||
$options = array_merge([
|
||||
'class' => 'ProjectUrlGenerator',
|
||||
'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
|
||||
), $options);
|
||||
], $options);
|
||||
|
||||
return <<<EOF
|
||||
<?php
|
||||
@@ -75,16 +79,14 @@ EOF;
|
||||
/**
|
||||
* Generates PHP code representing an array of defined routes
|
||||
* together with the routes properties (e.g. requirements).
|
||||
*
|
||||
* @return string PHP code
|
||||
*/
|
||||
private function generateDeclaredRoutes()
|
||||
private function generateDeclaredRoutes(): string
|
||||
{
|
||||
$routes = "array(\n";
|
||||
$routes = "[\n";
|
||||
foreach ($this->getRoutes()->all() as $name => $route) {
|
||||
$compiledRoute = $route->compile();
|
||||
|
||||
$properties = array();
|
||||
$properties = [];
|
||||
$properties[] = $compiledRoute->getVariables();
|
||||
$properties[] = $route->getDefaults();
|
||||
$properties[] = $route->getRequirements();
|
||||
@@ -92,22 +94,20 @@ EOF;
|
||||
$properties[] = $compiledRoute->getHostTokens();
|
||||
$properties[] = $route->getSchemes();
|
||||
|
||||
$routes .= sprintf(" '%s' => %s,\n", $name, PhpMatcherDumper::export($properties));
|
||||
$routes .= sprintf(" '%s' => %s,\n", $name, CompiledUrlMatcherDumper::export($properties));
|
||||
}
|
||||
$routes .= ' )';
|
||||
$routes .= ' ]';
|
||||
|
||||
return $routes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates PHP code representing the `generate` method that implements the UrlGeneratorInterface.
|
||||
*
|
||||
* @return string PHP code
|
||||
*/
|
||||
private function generateGenerateMethod()
|
||||
private function generateGenerateMethod(): string
|
||||
{
|
||||
return <<<'EOF'
|
||||
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
|
||||
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
|
||||
{
|
||||
$locale = $parameters['_locale']
|
||||
?? $this->context->getParameter('_locale')
|
||||
@@ -116,7 +116,6 @@ EOF;
|
||||
if (null !== $locale && null !== $name) {
|
||||
do {
|
||||
if ((self::$declaredRoutes[$name.'.'.$locale][1]['_canonical_route'] ?? null) === $name) {
|
||||
unset($parameters['_locale']);
|
||||
$name .= '.'.$locale;
|
||||
break;
|
||||
}
|
||||
@@ -129,6 +128,14 @@ EOF;
|
||||
|
||||
list($variables, $defaults, $requirements, $tokens, $hostTokens, $requiredSchemes) = self::$declaredRoutes[$name];
|
||||
|
||||
if (isset($defaults['_canonical_route']) && isset($defaults['_locale'])) {
|
||||
if (!\in_array('_locale', $variables, true)) {
|
||||
unset($parameters['_locale']);
|
||||
} elseif (!isset($parameters['_locale'])) {
|
||||
$parameters['_locale'] = $defaults['_locale'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
|
||||
}
|
||||
EOF;
|
||||
|
@@ -27,6 +27,20 @@ use Symfony\Component\Routing\RouteCollection;
|
||||
*/
|
||||
class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInterface
|
||||
{
|
||||
private const QUERY_FRAGMENT_DECODED = [
|
||||
// RFC 3986 explicitly allows those in the query/fragment to reference other URIs unencoded
|
||||
'%2F' => '/',
|
||||
'%3F' => '?',
|
||||
// reserved chars that have no special meaning for HTTP URIs in a query or fragment
|
||||
// this excludes esp. "&", "=" and also "+" because PHP would treat it as a space (form-encoded)
|
||||
'%40' => '@',
|
||||
'%3A' => ':',
|
||||
'%21' => '!',
|
||||
'%3B' => ';',
|
||||
'%2C' => ',',
|
||||
'%2A' => '*',
|
||||
];
|
||||
|
||||
protected $routes;
|
||||
protected $context;
|
||||
|
||||
@@ -47,7 +61,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
* "?" and "#" (would be interpreted wrongly as query and fragment identifier),
|
||||
* "'" and """ (are used as delimiters in HTML).
|
||||
*/
|
||||
protected $decodedChars = array(
|
||||
protected $decodedChars = [
|
||||
// the slash can be used to designate a hierarchical structure and we want allow using it with this meaning
|
||||
// some webservers don't allow the slash in encoded form in the path for security reasons anyway
|
||||
// see http://stackoverflow.com/questions/4069002/http-400-if-2f-part-of-get-url-in-jboss
|
||||
@@ -65,7 +79,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
'%21' => '!',
|
||||
'%2A' => '*',
|
||||
'%7C' => '|',
|
||||
);
|
||||
];
|
||||
|
||||
public function __construct(RouteCollection $routes, RequestContext $context, LoggerInterface $logger = null, string $defaultLocale = null)
|
||||
{
|
||||
@@ -110,7 +124,7 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
|
||||
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
|
||||
{
|
||||
$route = null;
|
||||
$locale = $parameters['_locale']
|
||||
@@ -120,7 +134,6 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
if (null !== $locale) {
|
||||
do {
|
||||
if (null !== ($route = $this->routes->get($name.'.'.$locale)) && $route->getDefault('_canonical_route') === $name) {
|
||||
unset($parameters['_locale']);
|
||||
break;
|
||||
}
|
||||
} while (false !== $locale = strstr($locale, '_', true));
|
||||
@@ -133,15 +146,28 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
// the Route has a cache of its own and is not recompiled as long as it does not get modified
|
||||
$compiledRoute = $route->compile();
|
||||
|
||||
return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostTokens(), $route->getSchemes());
|
||||
$defaults = $route->getDefaults();
|
||||
$variables = $compiledRoute->getVariables();
|
||||
|
||||
if (isset($defaults['_canonical_route']) && isset($defaults['_locale'])) {
|
||||
if (!\in_array('_locale', $variables, true)) {
|
||||
unset($parameters['_locale']);
|
||||
} elseif (!isset($parameters['_locale'])) {
|
||||
$parameters['_locale'] = $defaults['_locale'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->doGenerate($variables, $defaults, $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostTokens(), $route->getSchemes());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route
|
||||
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
|
||||
* it does not match the requirement
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array())
|
||||
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = [])
|
||||
{
|
||||
$variables = array_flip($variables);
|
||||
$mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters);
|
||||
@@ -156,21 +182,25 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
$message = 'Parameter "{parameter}" for route "{route}" must match "{expected}" ("{given}" given) to generate a corresponding URL.';
|
||||
foreach ($tokens as $token) {
|
||||
if ('variable' === $token[0]) {
|
||||
if (!$optional || !array_key_exists($token[3], $defaults) || null !== $mergedParams[$token[3]] && (string) $mergedParams[$token[3]] !== (string) $defaults[$token[3]]) {
|
||||
// check requirement
|
||||
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
|
||||
$varName = $token[3];
|
||||
// variable is not important by default
|
||||
$important = $token[5] ?? false;
|
||||
|
||||
if (!$optional || $important || !\array_key_exists($varName, $defaults) || (null !== $mergedParams[$varName] && (string) $mergedParams[$varName] !== (string) $defaults[$varName])) {
|
||||
// check requirement (while ignoring look-around patterns)
|
||||
if (null !== $this->strictRequirements && !preg_match('#^'.preg_replace('/\(\?(?:=|<=|!|<!)((?:[^()\\\\]+|\\\\.|\((?1)\))*)\)/', '', $token[2]).'$#i'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]] ?? '')) {
|
||||
if ($this->strictRequirements) {
|
||||
throw new InvalidParameterException(strtr($message, array('{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]])));
|
||||
throw new InvalidParameterException(strtr($message, ['{parameter}' => $varName, '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$varName]]));
|
||||
}
|
||||
|
||||
if ($this->logger) {
|
||||
$this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]));
|
||||
$this->logger->error($message, ['parameter' => $varName, 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$varName]]);
|
||||
}
|
||||
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
$url = $token[1].$mergedParams[$token[3]].$url;
|
||||
$url = $token[1].$mergedParams[$varName].$url;
|
||||
$optional = false;
|
||||
}
|
||||
} else {
|
||||
@@ -190,10 +220,10 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
// the path segments "." and ".." are interpreted as relative reference when resolving a URI; see http://tools.ietf.org/html/rfc3986#section-3.3
|
||||
// so we need to encode them as they are not used for this purpose here
|
||||
// otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route
|
||||
$url = strtr($url, array('/../' => '/%2E%2E/', '/./' => '/%2E/'));
|
||||
if ('/..' === substr($url, -3)) {
|
||||
$url = strtr($url, ['/../' => '/%2E%2E/', '/./' => '/%2E/']);
|
||||
if (str_ends_with($url, '/..')) {
|
||||
$url = substr($url, 0, -2).'%2E%2E';
|
||||
} elseif ('/.' === substr($url, -2)) {
|
||||
} elseif (str_ends_with($url, '/.')) {
|
||||
$url = substr($url, 0, -1).'%2E';
|
||||
}
|
||||
|
||||
@@ -212,16 +242,17 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
$routeHost = '';
|
||||
foreach ($hostTokens as $token) {
|
||||
if ('variable' === $token[0]) {
|
||||
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#i'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
|
||||
// check requirement (while ignoring look-around patterns)
|
||||
if (null !== $this->strictRequirements && !preg_match('#^'.preg_replace('/\(\?(?:=|<=|!|<!)((?:[^()\\\\]+|\\\\.|\((?1)\))*)\)/', '', $token[2]).'$#i'.(empty($token[4]) ? '' : 'u'), $mergedParams[$token[3]])) {
|
||||
if ($this->strictRequirements) {
|
||||
throw new InvalidParameterException(strtr($message, array('{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]])));
|
||||
throw new InvalidParameterException(strtr($message, ['{parameter}' => $token[3], '{route}' => $name, '{expected}' => $token[2], '{given}' => $mergedParams[$token[3]]]));
|
||||
}
|
||||
|
||||
if ($this->logger) {
|
||||
$this->logger->error($message, array('parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]));
|
||||
$this->logger->error($message, ['parameter' => $token[3], 'route' => $name, 'expected' => $token[2], 'given' => $mergedParams[$token[3]]]);
|
||||
}
|
||||
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
$routeHost = $token[1].$mergedParams[$token[3]].$routeHost;
|
||||
@@ -238,16 +269,18 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
}
|
||||
}
|
||||
|
||||
if ((self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) && !empty($host)) {
|
||||
$port = '';
|
||||
if ('http' === $scheme && 80 != $this->context->getHttpPort()) {
|
||||
$port = ':'.$this->context->getHttpPort();
|
||||
} elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
|
||||
$port = ':'.$this->context->getHttpsPort();
|
||||
}
|
||||
if (self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) {
|
||||
if ('' !== $host || ('' !== $scheme && 'http' !== $scheme && 'https' !== $scheme)) {
|
||||
$port = '';
|
||||
if ('http' === $scheme && 80 !== $this->context->getHttpPort()) {
|
||||
$port = ':'.$this->context->getHttpPort();
|
||||
} elseif ('https' === $scheme && 443 !== $this->context->getHttpsPort()) {
|
||||
$port = ':'.$this->context->getHttpsPort();
|
||||
}
|
||||
|
||||
$schemeAuthority = self::NETWORK_PATH === $referenceType ? '//' : "$scheme://";
|
||||
$schemeAuthority .= $host.$port;
|
||||
$schemeAuthority = self::NETWORK_PATH === $referenceType || '' === $scheme ? '//' : "$scheme://";
|
||||
$schemeAuthority .= $host.$port;
|
||||
}
|
||||
}
|
||||
|
||||
if (self::RELATIVE_PATH === $referenceType) {
|
||||
@@ -269,14 +302,12 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
|
||||
unset($extra['_fragment']);
|
||||
}
|
||||
|
||||
if ($extra && $query = http_build_query($extra, '', '&', PHP_QUERY_RFC3986)) {
|
||||
// "/" and "?" can be left decoded for better user experience, see
|
||||
// http://tools.ietf.org/html/rfc3986#section-3.4
|
||||
$url .= '?'.strtr($query, array('%2F' => '/'));
|
||||
if ($extra && $query = http_build_query($extra, '', '&', \PHP_QUERY_RFC3986)) {
|
||||
$url .= '?'.strtr($query, self::QUERY_FRAGMENT_DECODED);
|
||||
}
|
||||
|
||||
if ('' !== $fragment) {
|
||||
$url .= '#'.strtr(rawurlencode($fragment), array('%2F' => '/', '%3F' => '?'));
|
||||
$url .= '#'.strtr(rawurlencode($fragment), self::QUERY_FRAGMENT_DECODED);
|
||||
}
|
||||
|
||||
return $url;
|
||||
|
@@ -34,25 +34,25 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
|
||||
/**
|
||||
* Generates an absolute URL, e.g. "http://example.com/dir/file".
|
||||
*/
|
||||
const ABSOLUTE_URL = 0;
|
||||
public const ABSOLUTE_URL = 0;
|
||||
|
||||
/**
|
||||
* Generates an absolute path, e.g. "/dir/file".
|
||||
*/
|
||||
const ABSOLUTE_PATH = 1;
|
||||
public const ABSOLUTE_PATH = 1;
|
||||
|
||||
/**
|
||||
* Generates a relative path based on the current request path, e.g. "../parent-file".
|
||||
*
|
||||
* @see UrlGenerator::getRelativePath()
|
||||
*/
|
||||
const RELATIVE_PATH = 2;
|
||||
public 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 = 3;
|
||||
public const NETWORK_PATH = 3;
|
||||
|
||||
/**
|
||||
* Generates a URL or path for a specific route based on the given parameters.
|
||||
@@ -71,9 +71,9 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
|
||||
*
|
||||
* The special parameter _fragment will be used as the document fragment suffixed to the final URL.
|
||||
*
|
||||
* @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)
|
||||
* @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
|
||||
*
|
||||
@@ -82,5 +82,5 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
|
||||
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
|
||||
* it does not match the requirement
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH);
|
||||
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH);
|
||||
}
|
||||
|
Reference in New Issue
Block a user