/** * Send a success error message. * * @param string $message The error message to send. * @param object|array|string $object An object to send back to the output. * @return string|array The success response */ public function success($message = '', $object = null) { return $this->process($message, true, $object); } /** * Converts an object or objects embedded in an array, to arrays. * * This function also makes sure that any members of the array are not PHP * resource types (e.g. database connections, file handles, etc.). * * @param array|xPDOObject|object $object An array or object to process. * @return array Returns an array representation of the object(s). */ public function toArray($object) { $array = array (); if (is_array($object)) { while (list ($key, $value) = each($object)) { if (!is_resource($value)) { if (is_object($value) || is_array($value)) { $array[$key] = $this->toArray($value); } else { $array[$key] = $value; } } } } elseif (is_object($object)) { if ($object instanceof xPDOObject) { $array = $this->toArray($object->toArray()); } else { $array = $this->toArray(get_object_vars($object)); } } if ($this->modx->getDebug() === true) $this->modx->log(xPDO::LOG_LEVEL_DEBUG, "modError::toArray() -- " . print_r($array, true)); return $array; } /** * Resets the error messages. */ public function reset() { $this->errors = array(); $this->message = ''; $this->total = 0; $this->status = true; } }