MODX function for return array or object from snippet
<?php
class Webdev {
function runAsFunction($name,$params = []){
global $modx;
if($s = $modx->getObject('modSnippet', [
'name' => $name,
])){
$s->loadScript();
$f = $s->getScriptName();
// $params = array('foo' => $foo);
$func = $f($params);
return $func;
}
}
}