簡體   English   中英

Symfony - 參數語法和重定向

[英]Symfony - parameters syntax and redirect

我在我的 Symfony 項目的 parameters.yml 中定義了我的自定義路由。

當我重定向時,我的函數使用用戶的 {hash} 發送該路由,但拋出錯誤。

必須定義參數“front_url2e6f62b5822e1b383ab409219f905d06”。

隨機數代表我的用戶哈希。

我的參數.yml

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

我是否需要在參數中以不同的方式定義我的 {hash} 路由部分,或者問題可能是別的什么?

也許問題出在我的重定向上?

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

}

我在我的 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