phalcon/cphalcon — pull request #2514 by guweigang (2014-06-10 08:38:52+00:00)
Title: Try to convert annotations::getMethod name to lowercase for comparing

We all know name of class::method in php is not case-sensitive, so if your type: http://test.com/foo/bar/isadmin in you browser, and actually the class::method is ```\Foo\BarController::isAdminAction()```, this is all OK. But if I want to do something with ```dispatcher``` and ```annotation```, such as permissions validation, I would get nothing if I try to do ```$annotation->getMethod("\Foo\BarController", "isadminAction")```.

This is what I did for permissions validation in ```disaptcher:beforeExecuteRoute``` event.

```php
public function beforeExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\Dispatcher $dispatcher)
{
$annotations = new \Phalcon\Annotations\Adapter\Memory();
$anno = $annotations->getMethod($dispatcher->getActiveController(), $dispatcher->getActiveMethod());
if($anno->count() == 0 || !$anno->has('acl')) {
return true;
}

$aclAnno = $anno->get('acl');

if($aclAnno->getNamedArgument("login") === true) {
if(!$this->di->has('user')) {
$this->needLogin();
return false;
}
}

if($aclAnno->getNamedArgument("auth") === true) {

$list = $this->di->get('user')->getAcl("deleted = 0");
if($list->count() == 0) {
$this->needAuth();
return false;
}
foreach ($list as $item) {
$isOK = true;
if($item->module != '*' && $this->module != $item->module) {
$isOK = false;
continue;
}
if($item->controller != '*' && $this->controller != $item->controller) {
$isOK = false;
continue;
}
if($item->action != '*' && $this->action != $item->action) {
$isOK = false;
continue;
}
if($isOK == true) return true;
}

$this->needAuth();
return false;
}

return true;
}
```