本文整理汇总了PHP中Symfony\Component\Routing\Generator\UrlGenerator::doGenerate方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlGenerator::doGenerate方法的具体用法?PHP UrlGenerator::doGenerate怎么用?PHP UrlGenerator::doGenerate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Routing\Generator\UrlGenerator
的用法示例。
在下文中一共展示了UrlGenerator::doGenerate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doGenerate
/**
* {@override}
*/
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $absolute)
{
if (is_object($parameters)) {
$parameters = $this->readObjectParameters($parameters, $variables);
}
return parent::doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $absolute);
}
示例2: doGenerate
/**
* @throws MissingMandatoryParametersException When route has some missing mandatory parameters
* @throws InvalidParameterException When a parameter value is not correct
*/
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = [])
{
$baseUrl = $this->getContext()->getBaseUrl();
if ($name[0] != '_' && ($locale = $this->getContext()->getParameter('_locale'))) {
$this->getContext()->setBaseUrl($baseUrl . '/' . $locale);
}
$result = parent::doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
$this->getContext()->setBaseUrl($baseUrl);
return $result;
}
示例3: doGenerate
/**
* {@inheritdoc}
*/
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = [])
{
$link = $name;
if ($params = array_intersect_key($parameters, array_flip(isset($defaults['_variables']) ? $defaults['_variables'] : $variables))) {
$link .= '?' . http_build_query($params);
if ($properties = $this->getRouteProperties($link)) {
list($variables, $defaults, $requirements, $tokens, $hostTokens, $requiredSchemes) = $properties;
}
}
if ($referenceType === self::LINK_URL) {
return $link;
}
return parent::doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
}
示例4: doGenerate
/**
* @param $variables
* @param $defaults
* @param $requirements
* @param $tokens
* @param $parameters
* @param $name
* @param $referenceType
* @param $hostTokens
* @param array $requiredSchemes
* @return null|string
*/
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = [])
{
if (is_object($parameters)) {
$object = $parameters;
$parameters = [];
} elseif (isset($parameters['object']) && is_object($parameters['object'])) {
$object = $parameters['object'];
unset($parameters['object']);
}
if (isset($object)) {
$mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters);
$requiredParams = array_diff_key(array_flip($variables), $mergedParams);
$parameters += $this->getParametersFromObject(array_keys($requiredParams), $object);
}
return BaseUrlGenerator::doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
}
示例5: doGenerate
/**
* Surcharge de l'url generator pour générer une route en fonction d'un objet (paramètre _object)
* Les paramètres passés directement à la route sont prioritaires par rapport aux champs de _object
* {@inheritdoc}
*/
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = [])
{
if (isset($defaults['_external']) && '' !== $this->context->getBaseUrl()) {
$oldBaseUrl = $this->context->getBaseUrl();
$this->context->setBaseUrl('');
}
if (isset($parameters['_object'])) {
$object = $parameters['_object'];
$parameters = array_merge($this->getParametersFromObject($variables, $object), $parameters);
unset($parameters['_object']);
}
$url = parent::doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
if (isset($oldBaseUrl)) {
$this->context->setBaseUrl($oldBaseUrl);
}
return $url;
}
示例6: doGenerate
/**
* @param $variables
* @param $defaults
* @param $requirements
* @param $tokens
* @param $parameters
* @param $name
* @param $referenceType
* @param $hostTokens
* @param array $requiredSchemes
* @return string
*/
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array())
{
if (array_key_exists(self::GENERATE_NORMAL_ROUTE, $parameters)) {
unset($parameters[self::GENERATE_NORMAL_ROUTE]);
return parent::doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
}
//use the cached version with my name - do the standard request if its not work
// dont generate assets
if (stripos($name, RouteLoader::ROUTE_BEGIN) !== 0 && stripos($name, '_assetic') !== 0) {
$routeNames = $this->generateRouteNames($name, $this->context->getParameters(), $defaults, $parameters, $variables, $requirements);
foreach ($routeNames as $routeName) {
try {
return $this->generate($routeName, $parameters, $referenceType);
} catch (RouteNotFoundException $e) {
}
}
}
return parent::doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
}
示例7: doGenerate
/**
* @inheritdoc
*/
protected function doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = array())
{
$parameters = $this->removeUnusedAutoParameters($this->automaticParameters, $parameters, $variables);
return parent::doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
}