public $serializer ='frontend\modules\v2\component\CustomSerializer',
public function actionSpecialFoApi()
{
if(rest_responce == true) {
/** @var \frontend\modules\v2\component\ApicoSerializer $serializer */
return Yii::createObject($this->serializer)->serialize($data);
return; //возможно это может надо???
}
}
Тут написано
yii\rest\Serializer
Serializes the given data into a format that can be easily turned into other formats.
You may override this method to support more object types.
Код не тестировал, сори)