Class FOFHalDocument

Description

Implementation of the Hypertext Application Language document in PHP. It can be used to provide hypermedia in a web service context.

  • since: 2.1

Located in /libraries/fof/hal/document.php (line 17)


	
			
Method Summary
 FOFHalDocument __construct ([mixed $data = null])
 void addData (stdClass $data, [boolean $overwrite = true])
 boolean addEmbedded (string $rel, FOFHalDocument $document, [boolean $overwrite = true])
 boolean addLink (string $rel, FOFHalLink $link, [boolean $overwrite = true])
 boolean addLinks (string $rel, array $links, [boolean $overwrite = true])
 array|stdClass getData ()
 array|FOFHalDocument getEmbedded ([string $rel = null])
 array getLinks ([string $rel = null])
 string render ([string $format = 'json'])
Methods
Constructor __construct (line 54)

Public constructor

  • access: public
FOFHalDocument __construct ([mixed $data = null])
  • mixed $data: The data of the document (usually, the resource state)
addData (line 105)

Add data to the document

  • access: public
void addData (stdClass $data, [boolean $overwrite = true])
  • stdClass $data: The data to add
  • boolean $overwrite: Should I overwrite existing data?
addEmbedded (line 136)

Add an embedded document

  • access: public
boolean addEmbedded (string $rel, FOFHalDocument $document, [boolean $overwrite = true])
  • string $rel: The relation of the embedded document to its container document
  • FOFHalDocument $document: The document to add
  • boolean $overwrite: Should I overwrite existing data with the same relation?
addLink (line 74)

Add a link to the document

  • return: True if the link was added to the collection
  • see: FOFHalLinks::addLink
  • access: public
boolean addLink (string $rel, FOFHalLink $link, [boolean $overwrite = true])
  • string $rel: The relation of the link to the document. See RFC 5988 http://tools.ietf.org/html/rfc5988#section-6.2.2 A document MUST always have a "self" link.
  • FOFHalLink $link: The actual link object
  • boolean $overwrite: When false and a link of $rel relation exists, an array of links is created. Otherwise the existing link is overwriten with the new one
addLinks (line 92)

Add links to the document

  • see: FOFHalLinks::addLinks
  • access: public
boolean addLinks (string $rel, array $links, [boolean $overwrite = true])
  • string $rel: The relation of the link to the document. See RFC 5988
  • array $links: An array of FOFHalLink objects
  • boolean $overwrite: When false and a link of $rel relation exists, an array of links is created. Otherwise the existing link is overwriten with the new one
getData (line 197)

Return the data attached to this document

  • access: public
array|stdClass getData ()
getEmbedded (line 176)

Returns the collection of embedded documents

  • access: public
array|FOFHalDocument getEmbedded ([string $rel = null])
  • string $rel: Optional; the relation to return the embedded documents for
getLinks (line 164)

Returns the collection of links of this document

  • access: public
array getLinks ([string $rel = null])
  • string $rel: The relation of the links to fetch. Skip to get all links.
render (line 212)

Instantiate and call a suitable renderer class to render this document into the specified format.

  • return: The rendered document
  • throws: RuntimeException If the format is unknown, i.e. there is no suitable renderer
  • access: public
string render ([string $format = 'json'])
  • string $format: The format to render the document into, e.g. 'json'

Documentation generated on Tue, 19 Nov 2013 15:01:37 +0100 by phpDocumentor 1.4.3