Tripal
Public Member Functions | Protected Attributes | List of all members
TripalWebServiceResource Class Reference
Inheritance diagram for TripalWebServiceResource:
Inheritance graph
[legend]

Public Member Functions

 disbleType ()
 
 enableType ()
 
 disableID ()
 
 enableID ()
 
 __construct ($service_path)
 
 addContextItem ($name, $iri)
 
 removeContextItem ($name, $iri)
 
 setType ($type)
 
 setServicePath ($service_path)
 
 setID ($id)
 
 getURI ($id)
 
 getID ()
 
 getType ()
 
 addProperty ($key, $value)
 
 getProperty ($key)
 
 getData ()
 
 getContext ()
 
 setContext ($resource)
 

Protected Attributes

 $id
 
 $type
 
 $context
 
 $data
 
 $service_path
 
 $disable_type = FALSE
 
 $disable_id = FALSE
 

Constructor & Destructor Documentation

◆ __construct()

TripalWebServiceResource::__construct (   $service_path)

Implements the constructor.

Parameters
$service_path

Member Function Documentation

◆ addContextItem()

TripalWebServiceResource::addContextItem (   $name,
  $iri 
)

Adds a term to the '@context' section for this resource.

This function should not be called directory. Rather, the addContextTerm() and addContextVocab() functions built into the TripalWebService class should be used as these will help ensure terms are added proper for the context of the web service.

Parameters
$nameThe term name.
$iriThe Internationalized Resource Identifiers or it's shortcut.

◆ addProperty()

TripalWebServiceResource::addProperty (   $key,
  $value 
)

Adds a new key/value pair to the web serivces response.

The value must either be a scalar or another TripalWebServiceResource object. If the same key is usesd multiple times then the resulting resource will be presented as an array of elements.

Parameters
unknown$keyThe name of the $key to add. This key must already be present in the web service context by first adding it using the addContextItem() member function.
unknown$valueThe value of the key which must either be a scalar or a TripalWebServiceResource instance.

◆ disableID()

TripalWebServiceResource::disableID ( )

Exclude the @id element form the data of this resource.

◆ disbleType()

TripalWebServiceResource::disbleType ( )

Exclude the @type element form the data of this resource.

◆ enableID()

TripalWebServiceResource::enableID ( )

Include the @id element form the data of this resource.

◆ enableType()

TripalWebServiceResource::enableType ( )

Include the @type element form the data of this resource.

◆ getContext()

TripalWebServiceResource::getContext ( )

Retrieves the data section of the resource.

The JSON-LD response constists of two sections the '@context' section and the data section. This function only returns the data section for this resource

Returns
An associative array containing the data section of the response.

Reimplemented in TripalWebServiceCollection.

◆ getData()

TripalWebServiceResource::getData ( )

Retrieves the data section of the resource.

The JSON-LD response constists of two sections the '@context' section and the data section. This function only returns the data section for this resource

Returns
An associative array containing the data section of the response.

Reimplemented in TripalWebServiceCollection.

◆ getID()

TripalWebServiceResource::getID ( )

Retrieves the unique identifier for this resource.

Every resource must have a unique Idientifer. In JSON-LD the '@id' element identifies the IRI for the resource which will include the unique identifier. The TraiplWebService to which a resource is added will build the IRIs but it needs the unique ID of each resource.

Returns
The unique identifier for the resource.

◆ getProperty()

TripalWebServiceResource::getProperty (   $key)

Retrieves the value of a property.

Parameters
$keyThe name of the property.
Thevalue of the property. This could be a scalar, array or a TripalWebService object.

◆ getType()

TripalWebServiceResource::getType ( )

Retrieves the type of this resource.

Returns
The name of the resource.

◆ getURI()

TripalWebServiceResource::getURI (   $id)

Retrieves the IRI for an entity of a given ID in this web service.

Parameters
$idThe unique identifier for the resource.

◆ removeContextItem()

TripalWebServiceResource::removeContextItem (   $name,
  $iri 
)

Removes a term for the '@context' section for this resource.

Parameters
$nameThe term name.
$iriThe Internationalized Resource Identifiers or it's shortcut.

◆ setContext()

TripalWebServiceResource::setContext (   $resource)

Copies the context from a given TripalWebService resource to this resource.

Parameters
$resource

◆ setID()

TripalWebServiceResource::setID (   $id)

Set's the unique identifier for the resource.

Every resource must have a unique Idientifer. In JSON-LD the '@id' element identifies the IRI for the resource which will include the unique identifier. The TraiplWebService to which a resource is added will build the IRIs but it needs the unique ID of each resource.

Parameters
$idThe unique identifier for the resource.

◆ setServicePath()

TripalWebServiceResource::setServicePath (   $service_path)

Sets the service path for this resource.

By default, the service path is provided to the constructor, but this function will allow it to be changed if needed.

Parameters
$service_pathThe URL for the service path.

◆ setType()

TripalWebServiceResource::setType (   $type)

Sets the resource type.

The type exist in the context of the web service.

Parameters
$typeThe type

Reimplemented in TripalWebServiceCollection.

Member Data Documentation

◆ $context

TripalWebServiceResource::$context
protected

The JSON-LD compatible context for this resource.

◆ $data

TripalWebServiceResource::$data
protected

Holds the data portion of the JSON-LD response for this resource.

◆ $disable_type

TripalWebServiceResource::$disable_type = FALSE
protected

All resources should have a @type and an @id. But, there are times when we don't want any, such as an array of unpblished properties (e.g. featureloc elements). These can be set to TRUE to disable.

◆ $id

TripalWebServiceResource::$id
protected

The unique identifier for this resource.

◆ $service_path

TripalWebServiceResource::$service_path
protected

The URL path that the service is providing to access this resource. This path plus the $id are concatenated to form the IRI for this resource.

◆ $type

TripalWebServiceResource::$type
protected

The unique type of resource. The type must exists in the context for the web service.


The documentation for this class was generated from the following file: