generateUrl() protected method

Generates a URL from the given parameters.
See also: UrlGeneratorInterface
protected generateUrl ( string $route, mixed $parameters = [], integer $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH ) : string
$route string The name of the route
$parameters mixed An array of parameters
$referenceType integer The type of reference (one of the constants in UrlGeneratorInterface)
return string The generated URL
コード例 #1
0
ファイル: ManageInfoSpot.php プロジェクト: lapoiz/WindServer2
 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
0
 /**
  * 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
0
ファイル: BaseController.php プロジェクト: EllynB/Incipio
 /**
  * {@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
0
ファイル: Helper.php プロジェクト: GregHubs/GestionRessources
 /**
  * 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
0
ファイル: AbstractController.php プロジェクト: stopsopa/utils
 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
0
 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
0
ファイル: ControllerTest.php プロジェクト: symfony/symfony
 public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
 {
     return parent::generateUrl($route, $parameters, $referenceType);
 }
コード例 #8
0
 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);
 }