Routing in service and contoller of symfony 3.4

I am a situation that when i create a url in my controller as

$projectInvestorDecline = $this->generateUrl(
            'project_investor_decline',
            [
                'project' => 1,
                'uuid'=>$sucInvestorContact->getUuid()
            ],
            UrlGeneratorInterface::ABSOLUTE_URL
        );  dump($projectInvestorDecline);
        die;

I am getting the output as

"http://localhost:8080/app_dev.php/project/decline/1/526f1de7-83d6-11ea-bef1-00e02d4a14d4"

which is correct .But when i created the same url in a service as

$projectInvestorDecline = $this->router->generate(
            'project_investor_decline',
            [
                'project' => 1,
                'uuid'=>$sucInvestorContact->getUuid()
            ],
            UrlGeneratorInterface::ABSOLUTE_PATH
        );

I am getting the output as

http://localhost/project/decline/1/526f15ee-83d6-11ea-bef1-00e02d4a14d4

which is different from the first one.
What i am i doing wrong..Could anyone help me..

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *