Elgg  Version 3.0
Response.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Ajax;
3 
11 
12  private $ttl = 0;
13  private $data = null;
14  private $cancelled = false;
15 
19  public function setTtl($ttl = 0) {
20  $this->ttl = (int) max($ttl, 0);
21  return $this;
22  }
23 
27  public function getTtl() {
28  return $this->ttl;
29  }
30 
34  public function setData(\stdClass $data) {
35  if (!property_exists($data, 'value')) {
36  throw new \InvalidArgumentException('$data must have a property "value"');
37  }
38  $this->data = $data;
39  return $this;
40  }
41 
45  public function getData() {
46  return $this->data;
47  }
48 
52  public function cancel() {
53  $this->cancelled = true;
54  return $this;
55  }
56 
60  public function isCancelled() {
61  return $this->cancelled;
62  }
63 }
isCancelled()
{Has the response been cancelled?bool}
Definition: Response.php:60
setTtl($ttl=0)
{Set the max-age for client caching.Time to cache in seconds self}
Definition: Response.php:19
setData(\stdClass $data)
{Set the response data.Response data. Must be able to be encoded in JSON. self}
Definition: Response.php:34
cancel()
{Cancel the response and send a 403 header.self}
Definition: Response.php:52
getData()
{Get the response data, which will be a stdClass object with property "value".}
Definition: Response.php:45
JSON endpoint response.
Definition: AjaxResponse.php:9
JSON endpoint response.
Definition: Response.php:10
getTtl()
{Get the max-age for client caching.int}
Definition: Response.php:27