crisu83 / yii-rights

Automatically exported from code.google.com/p/yii-rights
BSD 3-Clause "New" or "Revised" License
2 stars 4 forks source link

Implement support for method 'actions' of controllers #41

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. There is function "actions" in default controller SiteController, which 
declared class-based actions. And this actions doesn't include in "Generate 
items" of this module.

What is the expected output? What do you see instead?
Expected output is including actions from function "actions" to generating 
items.

What version of the product are you using? On what operating system?
1.2.0 (revision 142)

Please provide any additional information below.

Original issue reported on code.google.com by iksm...@gmail.com on 18 Feb 2011 at 7:36

GoogleCodeExporter commented 9 years ago
I already looked into this once and it wasn't that easy to do.

I'll accept this issue though and take a second look when I have time.

Original comment by Christof...@gmail.com on 27 Feb 2011 at 11:52

GoogleCodeExporter commented 9 years ago
I was able to add code for this:

Check this section:

$pi = pathinfo($controller['path']);
        $className = $pi['filename'];
        // check if this class is loaded
        if (!class_exists($className, $autoload = false)) {
            include($controller['path']);
        }
        try {
            if (class_exists($className)) {
                $o = new $className($id = time(), $module = '');
                $objActions = $o->actions();
                if (!empty($objActions)) {
                    foreach ($objActions as $name=>$class) {
                        $actions[strtolower($name)] = array(
                            'name' => $name,
                            'line' => 0
                        );
                    }
                }
            }
        } catch (Exception $e) {
            // ignore any exception that might happened
        }

From this GIST:
https://gist.github.com/1269919

Original comment by pentium10 on 7 Oct 2011 at 9:47