Symfony2:generateUrl()用于使用ParamConverter的路由或如何反向参数转换

Symfony2:generateUrl()用于使用ParamConverter的路由或如何反向参数转换,symfony,routes,Symfony,Routes,我在我的路线中使用了一个定制的ParamConverter,不仅是为了保持控制器的精简,而且是为了重用参数转换算法。它使用路由参数作为哈希映射的索引,并将请求参数设置为相应的值。工作起来很有魅力 class EntityParamConverter implements ParamConverterInterface { protected $classNames; public function __construct($classnames = array()) {

我在我的路线中使用了一个定制的ParamConverter,不仅是为了保持控制器的精简,而且是为了重用参数转换算法。它使用路由参数作为哈希映射的索引,并将请求参数设置为相应的值。工作起来很有魅力

class EntityParamConverter implements ParamConverterInterface
{
    protected $classNames;

    public function __construct($classnames = array())
    {
        $this->classNames = $classnames;
    }

    function apply(Request $request, ParamConverter $configuration)
    {
        $options = $configuration->getOptions();
        $paramName = $configuration->getName();
        $nameParam = isset($options['entity_name']) ? $options['entity_name'] : 'entityname';

        if (empty($request->get($nameParam))) {
            return false;
        }

        $entityName = $request->get($nameParam);

        if (empty($this->classNames[$entityName])) {
            return false;
        }

        $entityClass = $this->classNames[$entityName];
        $request->attributes->set($paramName, $entityClass);

        return true;
    }

    function supports(ParamConverter $configuration)
    {
        return empty($configuration->getClass());
    }
}
我的问题是,我不知道如何从控制器内生成该路由的URL,而不必告诉控制器有关哈希映射的信息。是否有一种方法可以逆转参数转换,或者这是一种错误的开始方法