I am using a Behavior to add an action to a few controllers, the oversimplified behavior is defined as
public class GreetBehavior extends Behavior {
public function sayHello() {
return "Hello"
}
public function actionGreet() {
return "Hello";
}
}
The behavior is attached successfully. From within a Controller (f.i. Person) method I can access sayHello
with $this->sayHello();
.
The actionGreet however, is not recognized if I call it from the address bar: ...index.php?r=person/greet
. It gives the message that it cannot be resolved. Is it possible to add actions to a controller with behaviors anyway? If so, can you give me a hint what to do/what I am doing wrong. If not, do you know an alternative?