loremipsum / route-generator-bundle
Symfony bundle to create routes to resources.
Package info
github.com/loremipsum/route-generator-bundle
Type:symfony-bundle
pkg:composer/loremipsum/route-generator-bundle
v0.4.2
2025-11-11 09:53 UTC
Requires
- php: >=7.1
- symfony/framework-bundle: ^4.0 || ^5.0 || ^6.0 || ^7.0
- symfony/http-foundation: ^4.0 || ^5.0 || ^6.0 || ^7.0
README
Symfony bundle to create routes to resources.
Example route handler
<?php namespace App\RouteHandlers; use App\Entity\User; use LoremIpsum\RouteGeneratorBundle\Model\RouteHandlerInterface; use Symfony\Component\Routing\RouterInterface; class DefaultRouteHandler implements RouteHandlerInterface { protected $router; public function __construct(RouterInterface $router) { $this->router = $router; } public function handle($value, $view = null, $context = []) { if ($value instanceof User) { return $this->router->generate('userView', array_merge(['user' => $value->getId()], $context)); } return null; } }
Example usage
{% if <entity> is routable %}
<a href="{{ pathTo(<entity>) }}">{{ <entity> }}</a>
{% else %}
{{ <entity> }}
{% endif %}