PHP Class FOF30\Hal\Document

See also: http://stateless.co/hal_specification.html
Mostrar archivo Open project: akeeba/fof Class Usage Examples

Public Methods

Method Description
__construct ( mixed $data = null ) Public constructor
addData ( stdClass $data, boolean $overwrite = true ) : void Add data to the document
addEmbedded ( string $rel, Document $document, boolean $overwrite = true ) : boolean Add an embedded document
addLink ( string $rel, Link $link, boolean $overwrite = true ) : boolean Add a link to the document
addLinks ( string $rel, array $links, boolean $overwrite = true ) : boolean Add links to the document
getData ( ) : array | stdClass Return the data attached to this document
getEmbedded ( string $rel = null ) : array | Document Returns the collection of embedded documents
getLinks ( string $rel = null ) : array Returns the collection of links of this document
render ( string $format = 'json' ) : string Instantiate and call a suitable renderer class to render this document into the specified format.

Method Details

__construct() public method

Public constructor
public __construct ( mixed $data = null )
$data mixed The data of the document (usually, the resource state)

addData() public method

Add data to the document
public addData ( stdClass $data, boolean $overwrite = true ) : void
$data stdClass The data to add
$overwrite boolean Should I overwrite existing data?
return void

addEmbedded() public method

Add an embedded document
public addEmbedded ( string $rel, Document $document, boolean $overwrite = true ) : boolean
$rel string The relation of the embedded document to its container document
$document Document The document to add
$overwrite boolean Should I overwrite existing data with the same relation?
return boolean

getData() public method

Return the data attached to this document
public getData ( ) : array | stdClass
return array | stdClass

getEmbedded() public method

Returns the collection of embedded documents
public getEmbedded ( string $rel = null ) : array | Document
$rel string Optional; the relation to return the embedded documents for
return array | Document

render() public method

Instantiate and call a suitable renderer class to render this document into the specified format.
public render ( string $format = 'json' ) : string
$format string The format to render the document into, e.g. 'json'
return string The rendered document