yii\rest\Serializer collectionEnvelope

Hi everyone,

I’ve used the $collectionEnvelope property of yii\rest\Serializer and I’ve noticed that it’s only used when multiple items are retrieved. Is there an equivalent to prepend to single items?

I’d like to have something like this:

/api/v1/posts (this is already done by using $collectionEnvelope)




{

  "posts": [

    {

      "id": 1,

      "title": "Post 1",

      "author": "Post 1 author"

    },

    {

      "id": 2,

      "title": "Post 2",

      "author": "Post 2 author"

    }

  ]

}



/api/v1/posts/1




{

  "post": {

      "id": 1,

      "title": "Post 1",

      "author": "Post 1 author"

    }

}



Thanks

Anyone?