The following works for me now:
<?php
if(!$modx->user->hasSessionContext($modx->context->get('key'))){
return;
}
$tpl = $modx->getOption('tpl', $scriptProperties, 'videoItem');
$resourceGroup = $modx->getObject('modResourceGroup',array('name' => $modx->getLoginUserName($modx->context->get('key'))));
if(!$resourceGroup) { return; }
$resources = $resourceGroup->getResources();
$ids = [];
foreach ($resources as $resource) {
$ids[] = $resource->get('id');
}
return $modx->runSnippet('getResources', array(
'parents' => -1,
'resources' => implode(',',$ids),
'limit' => 0,
'tpl' => $tpl,
'includeTVs' => 1,
'tvPrefix' => ''
));
Since I need to render everything in the end with chunks including template variables, I figured why not use getResources that already does it all for me. I'm sure the way to get the resource Ids could be simplified with a simple sql query...
However I'm not very sure how to use the xpdo then. Once I have my resourceGroup object I run getResources on it, which is:
public function getResources() {
$c= $this->xpdo->newQuery('modResource');
$c->innerJoin('modResourceGroupResource', 'ResourceGroupResources');
$c->where(array ('ResourceGroupResources.document_group' => $this->get('id')));
return $this->xpdo->getCollection('modResource', $c);
}
So it makes a query for modResource objects and to me it looks like it will return modResource objects. However what I get in return is a collection of modDocument_mysql objects. That I can not wrap my head around.