<?php
namespace App\Helper;
use Symfony\Component\Routing\RouterInterface;
class Routes
{
private $routes = [];
public function __construct(RouterInterface $router)
{
foreach ($router->getRouteCollection()->all() as $route_name => $route) {
// if ( $route->getPath()[1] == '_' ) continue;
// dd( $route );
$this->routes[$route_name] = [
'path' => $route->getPath(),
'requirements' => $route->getRequirements(),
'defaults' => $route->getDefaults(),
'methods' => $route->getMethods(),
];
}
}
public function getRoutes(): array
{
return $this->routes;
}
}