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

2.0.6 - Bug on getActiveMethod in dispatcher #10755

Closed
FirePro opened this issue Aug 3, 2015 · 8 comments
Closed

2.0.6 - Bug on getActiveMethod in dispatcher #10755

FirePro opened this issue Aug 3, 2015 · 8 comments

Comments

@FirePro
Copy link

FirePro commented Aug 3, 2015

Hello!

I having actions in controllers like "helloMyWorldAction", and using annotations to route. If i try to $dispatcher->getActiveMethod() i get string like "hellomyworldAction"

Lost the original formatting of the text, it converted to lowercase.

This bug was corrected in Phalcon 1.3 *, but again returned to the Phalcon 2.0

@FirePro
Copy link
Author

FirePro commented Aug 3, 2015

A bug in version 1.3 are discussed here #2313

@andresgutierrez
Copy link
Contributor

Views are looked up in lowercase, returning helloMyWorldAction makes it look for a view called helloMyWorld.phtml instead of hellomyworld.phtml

@FirePro
Copy link
Author

FirePro commented Aug 3, 2015

What decision should be to get existing Annotations on active method without extra code?

Before update to 2.0, this

$annotations = $this->annotations->getMethod(
            $this->dispatcher->getControllerClass(),
           $this->dispatcher->getActiveMethod()
 );

After update to 2.0.6, It took me to write a function:

$activeMethod = $this->dispatcher->getActionName()."action";
$methods = $this->annotations->getMethods($this->dispatcher->getControllerClass());
foreach ($methods as $key => $value) {
       if (strtolower($key)==$activeMethod) {
                $activeMethod = $key;
       }
}

$annotations = $this->annotations->getMethod(
            $this->dispatcher->getControllerClass(),
            $activeMethod
);

@andresgutierrez
Copy link
Contributor

I think the annotations component must work with case insensitive method names and it does not matter in PHP

@FirePro
Copy link
Author

FirePro commented Aug 3, 2015

If you send to $annotations->getMethod lowercase method parameter, you don't get any annotations. If you send formatted string, you get all annotations.

@andresgutierrez
Copy link
Contributor

Yeah, that's what I'm saying, the annotations component must return the annotations for the method without having into account the case sensitiveness.

@FirePro
Copy link
Author

FirePro commented Aug 3, 2015

It would be great, if it will work as you said :) But now getMethod is case-sensitive and required the original name of active method.

@andresgutierrez
Copy link
Contributor

I've added case insensitiveness to getMethod in the 2.0.x branch

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