Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Zend_Json_Server_Response_Http Class Reference
Inheritance diagram for Zend_Json_Server_Response_Http:
Zend_Json_Server_Response

Public Member Functions

 toJson ()
 
 sendHeaders ()
 
- Public Member Functions inherited from Zend_Json_Server_Response
 setResult ($value)
 
 getResult ()
 
 setError (Zend_Json_Server_Error $error)
 
 getError ()
 
 isError ()
 
 setId ($name)
 
 getId ()
 
 setVersion ($version)
 
 getVersion ()
 
 toJson ()
 
 getArgs ()
 
 setArgs ($args)
 
 setServiceMap ($serviceMap)
 
 getServiceMap ()
 
 __toString ()
 

Additional Inherited Members

- Protected Attributes inherited from Zend_Json_Server_Response
 $_error
 
 $_id
 
 $_result
 
 $_serviceMap
 
 $_version
 

Detailed Description

Definition at line 33 of file Http.php.

Member Function Documentation

◆ sendHeaders()

sendHeaders ( )

Send headers

If headers are already sent, do nothing. If null ID, send HTTP 204 header. Otherwise, send content type header based on content type of service map.

Returns
void

Definition at line 61 of file Http.php.

62  {
63  if (headers_sent()) {
64  return;
65  }
66 
67  if (!$this->isError() && (null === $this->getId())) {
68  header('HTTP/1.1 204 No Content');
69  return;
70  }
71 
72  if (null === ($smd = $this->getServiceMap())) {
73  return;
74  }
75 
76  $contentType = $smd->getContentType();
77  if (!empty($contentType)) {
78  header('Content-Type: ' . $contentType);
79  }
80  }

◆ toJson()

toJson ( )

Emit JSON

Send appropriate HTTP headers. If no Id, then return an empty string.

Returns
string

Definition at line 42 of file Http.php.

43  {
44  $this->sendHeaders();
45  if (!$this->isError() && null === $this->getId()) {
46  return '';
47  }
48 
49  return parent::toJson();
50  }

The documentation for this class was generated from the following file: