Example #1
0
 /**
  * Creates a formatted response from the data provided.
  *
  * @param mixed $data        Data to include in the response.
  * @param int   $http_status HTTP Code.
  * @return Response
  */
 protected function response($data = array(), $http_status = null)
 {
     $output_single = !is_array($data);
     $output = $output_single ? array($data) : $data;
     foreach ($output as $key => $value) {
         if ($value instanceof \Orm\Model) {
             if (method_exists($value, 'to_api_array')) {
                 $output[$key] = $value->to_api_array();
             } else {
                 $output[$key] = $value->to_array();
             }
         } else {
             $output[$key] = $value;
         }
     }
     $output = $output_single ? current($output) : $output;
     return parent::response($output, $http_status);
 }
Example #2
0
 public function before()
 {
     parent::before();
 }