Elgg\Ajax\Response::setData PHP Method

setData() public method

public setData ( stdClass $data )
$data stdClass
    public function setData(\stdClass $data)
    {
        if (!property_exists($data, 'value')) {
            throw new \InvalidArgumentException('$data must have a property "value"');
        }
        $this->data = $data;
        return $this;
    }

Usage Example

Esempio n. 1
0
 /**
  * Send a JSON HTTP response with the given output
  *
  * @param mixed  $output     Output from a page/action handler
  * @param string $hook_type  The hook type. If given, the response will be filtered by hook
  * @param bool   $try_decode Try to convert a JSON string back to an abject
  * @return void
  */
 public function respondFromOutput($output, $hook_type = '', $try_decode = true)
 {
     if ($try_decode) {
         $output = $this->decodeJson($output);
     }
     $api_response = new Response();
     $api_response->setData($output);
     $api_response = $this->filterApiResponse($api_response, $hook_type);
     $response = $this->buildHttpResponse($api_response);
     $this->response_sent = true;
     $response->send();
 }
All Usage Examples Of Elgg\Ajax\Response::setData