Reputation: 3
I want to set a default value for city to "ABC", how can I do that in this code? Also, are there any examples for me to add multiple routes to this collection?
<?php
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
$collection = new RouteCollection();
$collection->add('hello_world_first_homepage', new Route('/weather/{city}', array(
'_controller' => 'HelloWorldFirstBundle:Default:index',
)));
return $collection;
Upvotes: 0
Views: 96
Reputation: 13891
As defined here, the Route constructor take as a second parameter an array of default values.
You can then add 'city' => "ABC'
to the array you're using to intitialize your new route.
Upvotes: 2