get return from run

Would it be wrong if a call to run() could return some data from the action?





    public function actionFoo() {

        return 'bar';

    }


    $result = $controller->run('foo');




What’s the purpose of doing that?

Say I have an action that gets called via ajax and returns some data.

But I also have a view that can use that data so a simple call to run() would return it too.

Just trying to avoid replicating.

AJAX actions are typically echoing json_encoded data rather than returning it.

Why not moving a common portion of this action into a regular controller method?

result of action?????

I could do that, but was trying to keep the code in the controller to a minimum by removing infrequently used code into CAction classes.

Maybe an extra method,




    $controller->runWithReturn('action');


    public class action extends CAction {

        public function run() {

            return $this->shouldReturn ? 'myresult' : die(json_encode(...));

        }

    }



Non-action code can be moved either to a base class or a behavior. No need to use CAction for it.