chrisdempsey
6/23/2014 - 6:49 PM

MODX function for return array or object from snippet

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;
        }
    }
}