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
Example #1
0
 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;
 }
 /**
  * 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);
 }
Example #3
0
 /**
  * {@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);
 }
Example #4
0
 /**
  * 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);
 }
Example #5
0
 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;
     }
 }
 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'));
 }
Example #7
0
 public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
 {
     return parent::generateUrl($route, $parameters, $referenceType);
 }
 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);
 }