Change data before sending through Yii2 RestAPI


I’m trying to change things before sending data.

I could do it for INDEX (GET all items from a model) with this:

class StuffController extends ActiveController


	public function actions() {

	$actions['index']['prepareDataProvider'] = [$this, 'prepareDataProviderIndex'];    

        return $actions;


but I tried to do the same with VIEW (GET just one item from a model) in the same way and I get

Unknown Property – yii\base\UnknownPropertyException

Setting unknown property: yii\rest\ViewAction::prepareDataProvider

Any idea ?

thank you !