Behaviors when operating as RESTful.

I am following the instructions* on how to create a RESTful service with Yii2 but the behavior method causes the error:

Response content must not be an array.

If I remove the behavior method then I receive the JSON response that I expect. I tried removing the behavior method after reading another post**.

However I am a little unfamiliar with behaviors. Can we not use behaviors with Yii2 with REST or is this a bug? I would be very appreciate if someone could shed some light on this.