public function getRoutes()
{
$routes = [];
$router = $this->getDI()->get('router');
foreach ($router->getRoutes() as $route) {
/** @var \Phalcon\Mvc\Router\Route $route */
$paths = $route->getPaths();
$pathsString = '';
if (isset($paths['module'])) {
$pathsString .= $paths['module'];
$module = $paths['module'];
} else {
$module = '';
}
if (isset($paths['namespace'])) {
$pathsString .= '\\' . ltrim($paths['namespace'], '\\');
}
if (isset($paths['controller'])) {
$pathsString .= '\\' . \Phalcon\Text::camelize(ltrim($paths['controller'], '\\'));
}
if (isset($paths['action'])) {
$pathsString .= '::' . $paths['action'];
}
$routes[$route->getRouteId()] = (object) [
'name' => $route->getName(),
'http_methods' => $route->getHttpMethods(),
'host_name' => $route->getHostname(),
'pattern' => $route->getPattern(),
'before_match' => $route->getBeforeMatch(),
'compiled_pattern' => $route->getCompiledPattern(),
'group' => $route->getGroup(),
'converters' => $route->getConverters(),
'paths' => $pathsString,
'module' => $module,
];
}
return $routes;
}