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