简体   繁体   English

Symfony - 参数语法和重定向

[英]Symfony - parameters syntax and redirect

I defined my custom route in parameters.yml in my Symfony project.我在我的 Symfony 项目的 parameters.yml 中定义了我的自定义路由。

When I am redirecting, my function is sending that route with {hash} of a user, but throwing an error.当我重定向时,我的函数使用用户的 {hash} 发送该路由,但抛出错误。

The parameter "front_url2e6f62b5822e1b383ab409219f905d06" must be defined.必须定义参数“front_url2e6f62b5822e1b383ab409219f905d06”。

The randon number represent my user hash.随机数代表我的用户哈希。

My parameters.yml我的参数.yml

parameters:
    front_url: 'https://my.custom-route.net/email/confirm/{hash}'

Do I need to define my {hash} route part in a different way in parameters or problem could be something else?我是否需要在参数中以不同的方式定义我的 {hash} 路由部分,或者问题可能是别的什么?

Maybe the problem is with my redirect?也许问题出在我的重定向上?

/**
 * @Route("/email/confirm/{hash}", name="email_confirm")
 */
public function confirmationEmailAction($hash)
{
    return $this->redirect($this->container->getParameter('front_url' . '/' . $hash));

}

I defined my custom route in parameters.yml in my Symfony project.我在我的 Symfony 项目的 parameters.yml 中定义了我的自定义路由。

// routes.yaml    
custom_routes:
    resource: 'custom_routes.yaml'
    prefix:   /

// custom_routes.yaml
front_url:
    path: '%front_url%'
    defaults:
        _controller: App\Controller\HashController:hash
        hash: false

parameters:
    front_url: 'https://my.custom-route.net/email/confirm/{hash}'       

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM