Symfony\Bundle\FrameworkBundle\Controller\Controller::generateUrl PHP Method

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
    protected function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
    {
        return $this->container->get('router')->generate($route, $parameters, $referenceType);
    }

Usage Example

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;
 }
All Usage Examples Of Symfony\Bundle\FrameworkBundle\Controller\Controller::generateUrl