PHP Source Code
function sanitizeObject($object, $keepFields = array()) { $out = array(); if ($keepFields) { $c=0; foreach ($keepFields as $field) { if ($obj instanceof xPDOObject){ $out[$c++][$field] = $object->get($field); } } } return $out; }
Comments
xPDO has an amazing ability of streamlining database to presentation translations, but in some scenarios simply providing an xPDO object to a presentation method, such as $modx->getchunk('chunkName', $object)
may allow undesirable information onto the page.
I created this function to sanitize Object values before they are sent to any display mechanism.
Implementation
sanitizeObject($obj, array('skuId', 'minAmount', 'maxAmount'))