Skip to content

Instantly share code, notes, and snippets.

@krukru
Created January 17, 2020 15:44
Show Gist options
  • Save krukru/89e0dca9110d7a4a771f7faef001e3ec to your computer and use it in GitHub Desktop.
Save krukru/89e0dca9110d7a4a771f7faef001e3ec to your computer and use it in GitHub Desktop.
<?php
// src/Service/SomeService.php
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class SomeService
{
private $router;
public function __construct(UrlGeneratorInterface $router)
{
$this->router = $router;
}
public function someMethod()
{
$url = $this->router->generate(
'my_unique_route_name'
);
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment