Something that would be nice to have would be a method to use getCollectionGraph to grab a collection using the modObjectGetListProcessor. I have to add a getData function to my getlist to add one line to use the getCollectionGraph. See example below:
public function getData() {
$data = array();
$limit = intval($this->getProperty('limit'));
$start = intval($this->getProperty('start'));
/* query for chunks */
$c = $this->modx->newQuery($this->classKey);
$c = $this->prepareQueryBeforeCount($c);
$data['total'] = $this->modx->getCount($this->classKey,$c);
$c = $this->prepareQueryAfterCount($c);
$sortClassKey = $this->getSortClassKey();
$sortKey = $this->modx->getSelectColumns($sortClassKey,$this->getProperty('sortAlias',$sortClassKey),'',array($this->getProperty('sort')));
if (empty($sortKey)) $sortKey = $this->getProperty('sort');
$c->sortby($sortKey,$this->getProperty('dir'));
if ($limit > 0) {
$c->limit($limit,$start);
}
//$data['results'] = $this->modx->getCollection($this->classKey,$c);
// modified this line from original modprocessor in my addon so I can use the getCollectionGraph
$data['results'] = $this->modx->getCollectionGraph($this->classKey, '{ "firstTable":{}, "secondTable":{ "subTable":{} } }',$c);
return $data;
}
Which works great, but it would just be nice to have something in the getData function in the core that said something like:
if($this->collectionGraph > ''){
$data['results'] = $this->modx->getCollectionGraph($this->classKey,$this->collectionGraph,$c);
}else{
$data['results'] = $this->modx->getCollection($this->classKey,$c);
}
return $data;
Where in the custom addon we can call the collection graph by just supplying the string we wish to use:
class customGetListProcessor extends modObjectGetListProcessor {
public $classKey = 'primaryTable';
public $collectionGraph = '{ "firstTable":{}, "secondTable":{ "subTable":{} } }';
....
And then we can modify the row data with the prepareRow function already available to display the data in the grid:
public function prepareRow(xPDOObject $object) {
$ta = $object->toArray('', false, true, true);
$ta['updated'] = $object->secondTable->subTable->updated;
$ta['logged_date'] = $object->firstTable->logged_date;
$ta['item_title'] = $object->secondTable->item_title;
return $ta;
}
While I'm sure this isn't something that would be used often, it sure would be nice to have for a summation screen before delving into the data maintenance in the manager.