Elgg  Version master
Response.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Ajax;
4 
6 
14 
15  private $ttl = 0;
16 
17  private $data = null;
18 
19  private $cancelled = false;
20 
24  public function setTtl($ttl = 0) {
25  $this->ttl = (int) max($ttl, 0);
26  return $this;
27  }
28 
32  public function getTtl() {
33  return $this->ttl;
34  }
35 
39  public function setData(\stdClass $data) {
40  if (!property_exists($data, 'value')) {
41  throw new InvalidArgumentException('$data must have a property "value"');
42  }
43 
44  $this->data = $data;
45  return $this;
46  }
47 
51  public function getData() {
52  return $this->data;
53  }
54 
58  public function cancel() {
59  $this->cancelled = true;
60  return $this;
61  }
62 
66  public function isCancelled() {
67  return $this->cancelled;
68  }
69 }
isCancelled()
{Has the response been cancelled?bool}
Definition: Response.php:66
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:24
setData(\stdClass $data)
{Set the response data.Response data. Must be able to be encoded in JSON. self}
Definition: Response.php:39
cancel()
{Cancel the response and send a 403 header.self}
Definition: Response.php:58
getData()
{Get the response data, which will be a stdClass object with property "value".}
Definition: Response.php:51
JSON endpoint response.
JSON endpoint response.
Definition: Response.php:13
getTtl()
{Get the max-age for client caching.int}
Definition: Response.php:32