Dojo data store format

The Dojo Toolkit define a common json format to ease the access of data from the server. This plugin allow a list of records to be formated allong this format and its result can be directly used by the Dojo "ItemFileReadStore".

Note, "label" and the "_reference" properties are not yet implemented.

Exemple


class User extends PorteRecord{
  public $meta_fields = array(
    'username' => array('type'=>'text')
  );
}

PorteConfig::$connection->users->update(array('drop'=>true));

$user = new User();
$user->setUsername('Adam');
$user->save();

$user = new User();
$user->setUsername('Eve');
$user->save();

echo PorteConfig::$connection->users->find()->toDojoStore(array('output'=>'json'))."\n";

// {"identifier":"id","items":[{"id":1,"username":"Adam"},{"id":2,"username":"Eve"}]}

Understanding the internal

This plugin listen to the "list_call_before" event and register the method "toDojoStore" to each PorteIterator instance.

Open Source Object Relational Mapping in PHP

Download Porte 0.2.1