예제 #1
0
 static function toArrayAll($obj, $callback = false)
 {
     if (method_exists($obj, "toArray")) {
         $jsonified = $obj->toArray();
     } else {
         if (is_array($obj)) {
             $jsonified = array();
             foreach ($obj as $key => $value) {
                 $jsonified[$key] = SC::toArrayAll($value);
             }
         } else {
             $jsonified = $obj;
         }
     }
     return $jsonified;
 }
예제 #2
0
 public function handleResponse($resp, $methodname)
 {
     $content_type = $this->getResponseContentType();
     switch ($content_type) {
         case "html":
             $partial = $this->{$methodname}(array("__partial" => true));
             if ($partial) {
                 $partial_name = $partial["partial"];
                 if (isset($partial["val"])) {
                     $resp = array($partial["val"] => $resp);
                 }
                 return SCPartial::renderToString($partial_name, $resp);
             }
             throw new APIException("There is no html associated with this.", 400);
             break;
         case "json":
             return SC::jsonify(SC::toArrayAll($resp));
             break;
     }
 }