yii-json-dataprovider

A data provider that extends CActiveDataProvider in order to retrieve an (configurable) json result
8 followers

A yii dataprovider that extends CActiveDataProvider in order to retrieve json. Attributes and relations that are fetched are recursively configurable. Furthermore key names can be replaced by aliases to compress the json size.

Feel free to contribute at GitHub.

Update on 06/11/2013

  1. Extracting the work horse that does the converting to new class ModelToArrayConverter. This class is usable stand-alone, too.
  2. New method getArrayCountData on JSonActiveDataProvider to retrieve just the count information, but no data.
  3. New callback onAfterModelToArray on JSonActiveDataProvider for optional custom extracting of data per model.
  4. For convenience relations can be defined now directly with an attributes description (instead of wrapping them into another array with a key "attributes")
  5. Examples at github readme updated

All changes do not break old behavior or usage!

Requirements

Developed with Yii 1.10, but should work in older versions, too.

Usage

See Readme on GitHub

Resources

Total 4 comments

#15896 report it
chux at 2013/12/27 06:06pm
Invalid argument supplied for foreach

Hi,

I think i've found a bug, i've submitted a pull request via github that fixes it ;)

https://github.com/sieppl/yii-json-dataprovider/pulls

#13493 report it
Sebastian K. at 2013/05/31 06:17pm
@farhad2161

Thank you for the note. your code is great for retrieving all information, but I needed a configurable approach to return just selected attributes and relations. In an Api scenario it does make sense to keep control on which information is provided exactly and to reduce data overhead.

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet