Solution looks something like this:
<?php namespace fastPanel\Mvc;
use Phalcon\Mvc\Router\Annotations;
/**
* Class Router
*
* Expansion of standard class annotations router.
*
* @package fastPanel\Mvc
* @version 1.0.0
*/
class Router extends Annotations {
/**
* Set all routes.
*
* @param array $routes
*/
public function setRoutes(array $routes) {
$this->_routes = $routes;
}
}
/* End of file Router.php */
/* Reordering routes. */
$manager->attach('router:beforeCheckRoutes', function ($event, \fastPanel\Mvc\Router $router) {
/* Route list to move. */
$moveRoutes = [
'Front:Abc:NamedPage:Locale',
'Front:Abc:NamedPage'
];
foreach ($moveRoutes as $route) {
/* Find target route. */
$namedRoute = $router->getRouteByName($route);
if ($namedRoute) {
/* Get all routes. */
$routes = $router->getRoutes();
/* Move target route. */
\fastPanel\Helpers\Arrays::moveAsFirst($routes, $namedRoute->getRouteId());
/* Set routes in new orders. */
$router->setRoutes($routes);
}
}
});