本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Controller\Controller::generateUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::generateUrl方法的具体用法?PHP Controller::generateUrl怎么用?PHP Controller::generateUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Controller\Controller
的用法示例。
在下文中一共展示了Controller::generateUrl方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createNewForm
public static function createNewForm(Controller $controller, Spot $spot)
{
$infoSpot = new InfoSpot();
$form = $controller->createForm(InfoSpotType::class, $infoSpot, array('action' => $controller->generateUrl('_bo_ajax_spot_add_spot_info', array('id' => $spot->getId())), 'method' => 'POST'));
$form->add('Create', SubmitType::class, array('label' => 'Create', 'attr' => array('class' => 'btn btn-default pull-right')));
return $form;
}
示例2: generateUrl
/**
* Generates a URL from the given parameters adding project id.
*
* @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
*
* @see UrlGeneratorInterface
*/
public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
{
if ($this->project) {
$mergedParameters = array_merge(array('id' => $this->project->getId()), $parameters);
}
return parent::generateUrl($route, $mergedParameters, $referenceType);
}
示例3: generateUrl
/**
* {@inheritdoc}
*/
public function generateUrl($route, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
{
if (array_key_exists('id', $parameters)) {
$parameters['id'] = IriHelper::extractId($parameters['id']);
}
return parent::generateUrl($route, $parameters, $referenceType);
}
示例4: getPath
/**
* Permet de récupérer la bon route en php
* @param $route
* @param $params
* @param string $locale
* @param Controller $controller
* @return string
*/
public function getPath($route, $params, $locale = 'fr', Controller $controller)
{
if ($locale !== 'fr') {
$route .= ucfirst($locale);
$params['_locale'] = $locale;
}
return $controller->generateUrl($route, $params);
}
示例5: generateUrl
public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
{
$name = $route;
if ($route instanceof Request) {
$name = $route->get('_route', 'error_no_route_specified');
}
try {
return parent::generateUrl($name, $parameters, $referenceType);
} catch (MissingMandatoryParametersException $ex) {
if ($route instanceof Request) {
return $route->getRequestUri();
}
throw $ex;
}
}
示例6: testGenerateUrl
public function testGenerateUrl()
{
$router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
$router->expects($this->once())->method('generate')->willReturn('/foo');
$container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
$container->expects($this->at(0))->method('get')->will($this->returnValue($router));
$controller = new Controller();
$controller->setContainer($container);
$this->assertEquals('/foo', $controller->generateUrl('foo'));
}
示例7: generateUrl
public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
{
return parent::generateUrl($route, $parameters, $referenceType);
}
示例8: generateUrl
public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
{
if (!array_key_exists('project', $parameters)) {
if (!is_null($this->project)) {
$parameters['project'] = $this->project->getIdentifier();
}
}
return parent::generateUrl($route, $parameters, $referenceType);
}