getData() public method

Get the response data, which will be a stdClass object with property "value"
public getData ( ) : stdClass
return stdClass
Ejemplo n.º 1
0
 /**
  * Build a JsonResponse based on an API response object
  *
  * @param AjaxResponse $api_response           The API Response
  * @param bool         $allow_removing_headers Alter PHP's global headers to allow caching
  *
  * @return JsonResponse
  * @throws \RuntimeException
  */
 private function buildHttpResponse(AjaxResponse $api_response, $allow_removing_headers = true)
 {
     if ($api_response->isCancelled()) {
         return new JsonResponse(['error' => "The response was cancelled"], 400);
     }
     $response = new JsonResponse(['msgs' => (object) $this->msgs->dumpRegister(), 'data' => $api_response->getData()]);
     $ttl = $api_response->getTtl();
     if ($ttl > 0) {
         // Required to remove headers set by PHP session
         if ($allow_removing_headers) {
             header_remove('Expires');
             header_remove('Pragma');
             header_remove('Cache-Control');
         }
         // JsonRequest sets a default Cache-Control header we don't want
         $response->headers->remove('Cache-Control');
         $response->setClientTtl($ttl);
         // if we don't set Expires, Apache will add a far-off max-age and Expires for us.
         $response->headers->set('Expires', gmdate('D, d M Y H:i:s \\G\\M\\T', time() + $ttl));
     }
     return $response;
 }
Ejemplo n.º 2
0
 /**
  * Send required AMD modules list back with the response
  *
  * @param string       $hook     "ajax_response"
  * @param string       $type     "all"
  * @param AjaxResponse $response Ajax response
  * @param array        $params   Hook params
  *
  * @return AjaxResponse
  * @access private
  * @internal
  */
 public function appendDeps($hook, $type, $response, $params)
 {
     if (!$response instanceof AjaxResponse) {
         return;
     }
     $response->getData()->_elgg_deps = (array) $this->amd_config->getDependencies();
     return $response;
 }