Elgg  Version 4.3
Response.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Ajax;
4 
6 
14 
15  private $ttl = 0;
16  private $data = null;
17  private $cancelled = false;
18 
22  public function setTtl($ttl = 0) {
23  $this->ttl = (int) max($ttl, 0);
24  return $this;
25  }
26 
30  public function getTtl() {
31  return $this->ttl;
32  }
33 
37  public function setData(\stdClass $data) {
38  if (!property_exists($data, 'value')) {
39  throw new InvalidArgumentException('$data must have a property "value"');
40  }
41  $this->data = $data;
42  return $this;
43  }
44 
48  public function getData() {
49  return $this->data;
50  }
51 
55  public function cancel() {
56  $this->cancelled = true;
57  return $this;
58  }
59 
63  public function isCancelled() {
64  return $this->cancelled;
65  }
66 }
isCancelled()
{Has the response been cancelled?bool}
Definition: Response.php:63
Exception thrown if an argument is not of the expected type.
setTtl($ttl=0)
{Set the max-age for client caching.Time to cache in seconds self}
Definition: Response.php:22
setData(\stdClass $data)
{Set the response data.Response data. Must be able to be encoded in JSON. self}
Definition: Response.php:37
cancel()
{Cancel the response and send a 403 header.self}
Definition: Response.php:55
getData()
{Get the response data, which will be a stdClass object with property "value".}
Definition: Response.php:48
JSON endpoint response.
Definition: AjaxResponse.php:9
JSON endpoint response.
Definition: Response.php:13
getTtl()
{Get the max-age for client caching.int}
Definition: Response.php:30