Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Actions by Behavioring

$
0
0
Is it possible to create a Behavior with some actions, and implement that Behavior in a Controller, using those actions transparently?

Example:
<?php
class ExampleBehavior extends CBehavior {

public function actionTesting() {

}

}

class CodeController extends CController {

[...]

public function behaviors() {
return array('test' => array('class'=>'ext.behaviors.ExampleBehavior'));
}

}
?>

Calling mysite.com/code/testing would say "The system is unable to find the requested action "testing".

I know the behavioring is successful because I can create an action inside the Controller and call actionTesting() inside it.

But is it possible to call the behavior's actions transparently? Or it's just an unexpected behavior from yii code? A bug?
Is there a "recommended" workaround?

Viewing all articles
Browse latest Browse all 18717


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>