简体   繁体   中英

Symfony - parameters syntax and redirect

I defined my custom route in parameters.yml in my Symfony project.

When I am redirecting, my function is sending that route with {hash} of a user, but throwing an error.

The parameter "front_url2e6f62b5822e1b383ab409219f905d06" must be defined.

The randon number represent my user hash.

My parameters.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?

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.

// 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}'       

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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