Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon\Mvc\Router get pattern based on a matched route

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


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) {
  string(10) "/realURL"
  string(10) "/realURL"
  array(2) {
    string(14) "exampleController"
    string(5) "login"

edited Jan '16

Well, thanks Rubber duck debugging :)

    var_dump($resolveRoute->getPattern()); //string "/loginPage"