0
я добавил следующий код в моем классе администратораКак добавить параметр маршрута в SonataAdminBundle Symfony2
class ProductPriceAdmin extends Admin
{
protected function configureRoutes(RouteCollection $collection)
{
parent::configureRoutes($collection);
$collection->add('price'); //I want to add a "id" as route parameter
}
}
Здесь цена моя пользовательская функция, которую я объявил в контроллере, как показано ниже,
class ProductPriceController extends Controller
{
public function priceAction($id) //I want to use this variable
{
if (false === $this->admin->isGranted('LIST')) {
throw new AccessDeniedException();
}
$datagrid = $this->admin->getDatagrid();
$formView = $datagrid->getForm()->createView();
// set the theme for the current Admin Form
$this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());
return $this->render($this->admin->getTemplate('list'), array(
'action' => 'list',
'form' => $formView,
'datagrid' => $datagrid,
'csrf_token' => $this->getCsrfToken('sonata.batch'),
));
}
}
Как добавить параметр маршрута при добавлении динамической маршрутизации?
Спасибо, Фейсал Насир