/**
  * Serve data to the client
  *
  * @param mixed $data
  * @param string $as
  * @param array $additional_describe_params
  * @param string $format
  * @param boolean $die
  * @return null
  */
 function serveData($data, $as = null, $additional_describe_params = null, $format = null, $die = true)
 {
     $to_encode = $data;
     // Error
     if (is_error($data)) {
         header("HTTP/1.1 417 Expectation Failed");
         $as = 'error';
         $to_encode = $data->describe();
         // Object with describe function
     } elseif (instance_of($data, 'AngieObject') && in_array('describe', get_class_methods(get_class($data)))) {
         $to_encode = $data->describe($this->logged_user, $additional_describe_params);
         // Everything else
     } elseif (is_array($data)) {
         $all_objects = true;
         foreach ($data as $v) {
             if (!instance_of($v, 'ApplicationObject')) {
                 $all_objects = false;
             }
             // if
         }
         // foreach
         if ($all_objects) {
             $to_encode = array();
             foreach ($data as $k => $v) {
                 $to_encode[$k] = $v->describe($this->logged_user, $additional_describe_params);
             }
             // foreach
         }
         // if
     }
     // if
     return parent::serveData($to_encode, $as, $format, $die);
 }