Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFR] Name property for Phalcon\Mvc\Router\Group #1682

Closed
moderndeveloperllc opened this issue Dec 12, 2013 · 6 comments
Closed

[NFR] Name property for Phalcon\Mvc\Router\Group #1682

moderndeveloperllc opened this issue Dec 12, 2013 · 6 comments

Comments

@moderndeveloperllc
Copy link

Allow users to setName() on a group as is done for individual routes. Individual routes should have a groupName attribute that contains this, or have a getGroup() function on Phalcon\Mvc\Router\Route that returns the Phalcon\Mvc\Router\Group object.

This would be useful when doing a getMatchedRoute() to be able to code logic based off of the group the matched route belongs to. I am currently writing a Locale class that does URL rewriting. All of my locale-aware routes are in one group and I want to check if the incoming URL already matches one of those routes our not.

Current Workaround: I'm using setName() on all the routes in the group to name them the same thing.

@ghost
Copy link

ghost commented Dec 20, 2013

Implemented in 1.3.0, could you please take a look?

@moderndeveloperllc
Copy link
Author

@sjinks Odd, but I'm getting Fatal error: Call to undefined method Phalcon\Mvc\Router\Route::getGroup() even though I've built out the 1.3.0 branch. I also can't see a _group attribute on the Phalcon\Mvc\Router\Route object.

1.3.0 BETA 1
Phalcon\Mvc\Router\Route Object
(
    [_pattern:protected] => /{locale:[a-z]{2,3}([\_\-][[:alnum:]]{1,8})?}/:controller/:action/:params
    [_compiledPattern:protected] => #^/[a-z]{2,3}([\_\-][[:alnum:]]{1,8})?/([a-zA-Z0-9_-]++)/([a-zA-Z0-9_-]++)(/.*+)?+$#
    [_paths:protected] => Array
        (
            [controller] => 2
            [action] => 3
            [params] => 4
            [locale] => 1
        )

    [_methods:protected] => 
    [_hostname:protected] => 
    [_converters:protected] => 
    [_id:protected] => 7
    [_name:protected] => LocaleAwareRoute
    [_beforeMatch:protected] => 
)

@ghost
Copy link

ghost commented Dec 23, 2013

Did you build 1.3.0 from build/ or from ext/?

@moderndeveloperllc
Copy link
Author

build/ Wrong place? :-)

@moderndeveloperllc
Copy link
Author

my bad - forgot to run gen-build.php. I now have the group object, but there is no way to identify if it's the right group. The NFR was also to get a setName()/getName() on the Group object.

@moderndeveloperllc
Copy link
Author

@sjinks Should I close this out? I was really hoping that Phalcon\Mvc\Router\Group would get a getName()/setName()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants