Skip to content

Instantly share code, notes, and snippets.

@Codenator81
Last active June 1, 2017 20:33
Show Gist options
  • Save Codenator81/e8508d84da0f8797f992 to your computer and use it in GitHub Desktop.
Save Codenator81/e8508d84da0f8797f992 to your computer and use it in GitHub Desktop.
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;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment