当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller::generateUrl方法代码示例

本文整理汇总了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;
 }
开发者ID:lapoiz,项目名称:WindServer2,代码行数:7,代码来源:ManageInfoSpot.php

示例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);
 }
开发者ID:sshversioncontrol,项目名称:git-web-client,代码行数:18,代码来源:BaseProjectController.php

示例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);
 }
开发者ID:EllynB,项目名称:Incipio,代码行数:10,代码来源:BaseController.php

示例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);
 }
开发者ID:GregHubs,项目名称:GestionRessources,代码行数:16,代码来源:Helper.php

示例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;
     }
 }
开发者ID:stopsopa,项目名称:utils,代码行数:15,代码来源:AbstractController.php

示例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'));
 }
开发者ID:neartux,项目名称:visitayucatan2.0,代码行数:10,代码来源:ControllerTest.php

示例7: generateUrl

 public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
 {
     return parent::generateUrl($route, $parameters, $referenceType);
 }
开发者ID:symfony,项目名称:symfony,代码行数:4,代码来源:ControllerTest.php

示例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);
 }
开发者ID:koalamon,项目名称:koalamonframeworkbundle,代码行数:9,代码来源:ProjectAwareController.php


注:本文中的Symfony\Bundle\FrameworkBundle\Controller\Controller::generateUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。