Hello community, I hit the wall with this one.
I need to get matched pattern by a name of the defined route.
Router groups are defined as:
$loginRoutes = new RouterGroup(['controller' => 'exampleController']);
$loginRoutes->add('/loginPage',['action' => 'login'])->setName('login');
So I want to resolve it by a named route (login in this case):
$routeName = 'login';
$resolveRoute = $this->_router->getRouteByName($routeName);
var_dump($resolveRoute); //returns proper route as object
var_dump($this->_router->getParams());
var_dump($this->_router->getControllerName());
var_dump($this->_router->getActionName());
var_dump($this->_router->getMatchedRoute());
The problem is, getRouteByName returns object with all properties defined as protected. I can see the pattern, but I cannot re-use it. Is there a way to fetch pattern from router component? I'm too tired at this point, I must be missing something.
This is the dump of it:
object(Phalcon\Mvc\Router\Route)#78 (10) {
["_pattern":protected]=>
string(10) "/realURL"
["_compiledPattern":protected]=>
string(10) "/realURL"
["_paths":protected]=>
array(2) {
["controller"]=>
string(14) "exampleController"
["action"]=>
string(5) "login"
}
}