PHP MVC自己主动RBAC自己主动生成的访问路由

使用的关键点:

ReflectionClass


class Rbac extends MY_Controller
{

    public function index()
    {
        $arr = glob(  __DIR__ .DIRECTORY_SEPARATOR. '*.php');
//        $arr = glob(dirname(__DIR__) . DIRECTORY_SEPARATOR . '*');
        $MVC = array();
        foreach ($arr as $path) {

            $basename = basename($path, '.php');

            //仅支持合法的命名
            if (preg_match('/^\w+$/', $basename) && $path != __FILE__) {
                require $path;
                $className = ucfirst($basename);
                $ref = new ReflectionClass($className);
                foreach ($ref->getMethods() as $key => $methods) {

                    var_dump( get_class_methods($methods));

                    if($methods->isPublic()){
                        $MVC[$methods->class][] = array(
                            $methods->getName(),
                            $methods->getFileName(),
                        );
                            $methods->name;
                    }
                }
            }
        }
        var_dump($MVC);
    }
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

posted @ 2015-09-13 21:53  zfyouxi  阅读(221)  评论(0编辑  收藏  举报