Last active
June 1, 2017 20:33
-
-
Save Codenator81/e8508d84da0f8797f992 to your computer and use it in GitHub Desktop.
MODX function for return array or object from snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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