Class FOFHalDocument
Implementation of the Hypertext Application Language document in PHP. It can
be used to provide hypermedia in a web service context.
Methods summary
public
|
#
__construct( mixed $data = null )
Public constructor
Parameters
- $data
mixed - $data The data of the document (usually, the resource state)
|
public
boolean
|
#
addLink( string $rel, FOFHalLink $link, boolean $overwrite = true )
Add a link to the document
Add a link to the document
Parameters
- $rel
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.
- $link
FOFHalLink - $link The actual link object
- $overwrite
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
Returns
boolean - True if the link was added to the collection
See
|
public
boolean
|
#
addLinks( string $rel, array $links, boolean $overwrite = true )
Add links to the document
Add links to the document
Parameters
- $rel
string - $rel The relation of the link to the document. See RFC 5988
- $links
array - $links An array of FOFHalLink objects
- $overwrite
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
Returns
boolean
See
|
public
|
#
addData( stdClass $data, boolean $overwrite = true )
Add data to the document
Parameters
- $data
stdClass - $data The data to add
- $overwrite
boolean - $overwrite Should I overwrite existing data?
|
public
boolean
|
#
addEmbedded( string $rel, FOFHalDocument $document, boolean $overwrite = true )
Add an embedded document
Parameters
- $rel
string - $rel The relation of the embedded document to its container document
- $document
FOFHalDocument - $document The document to add
- $overwrite
boolean - $overwrite Should I overwrite existing data with the same relation?
Returns
boolean
|
public
array
|
#
getLinks( string $rel = null )
Returns the collection of links of this document
Returns the collection of links of this document
Parameters
- $rel
string - $rel The relation of the links to fetch. Skip to get all links.
Returns
array
|
public
array|FOFHalDocument
|
#
getEmbedded( string $rel = null )
Returns the collection of embedded documents
Returns the collection of embedded documents
Parameters
- $rel
string - $rel Optional; the relation to return the embedded documents for
Returns
|
public
array|stdClass
|
#
getData( )
Return the data attached to this document
Return the data attached to this document
Returns
|
public
string
|
#
render( string $format = 'json' )
Instantiate and call a suitable renderer class to render this document into
the specified format.
Instantiate and call a suitable renderer class to render this document into
the specified format.
Parameters
- $format
string - $format The format to render the document into, e.g. 'json'
Returns
string - The rendered document
Throws
|
Magic methods summary