public function TripalWebService::addResourceProperty

3.x TripalWebService.inc public TripalWebService::addResourceProperty($resource, $term, $value, $sanitize = array())

Adds a key/value property to the given resource.

Parameters

$resource: A TripalWebServiceResource instance.

$term: The term array for the key.

$value: The value to add.

$santize: An array of keywords indicating how to santize the key. By default, no sanitizing occurs. The two valid types are 'lowercase', and 'spacing' where 'lowercase' converts the term name to all lowercase and 'spacing' replaces any spaces with underscores.

Return value

$key The key (the term name but with spaces replaced with underscores).

5 calls to TripalWebService::addResourceProperty()
TripalContentService_v0_1::addEntityField in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Adds the field as a property of the entity resource.
TripalContentService_v0_1::addEntityFields in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Adds the fields as properties of an entity resource.
TripalContentService_v0_1::doContentTypesList in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Creates a resources that contains the list of content types.
TripalContentService_v0_1::doEntity in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Creates a resource for a single entity.
TripalContentService_v0_1::doEntityList in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Creates a collection of resources for a given type.

File

tripal_ws/includes/TripalWebService.inc, line 704

Class

TripalWebService

Code

public function addResourceProperty($resource, $term, $value, $sanitize = array()) {
  if (!is_a($resource, 'TripalWebServiceResource')) {
    throw new Exception('addProperty: Please provide a $resource of type TripalWebServiceResource.');
  }

  // First add the term
  $key = $this->addContextTerm($resource, $term, $sanitize);

  // Then add the property.
  $resource->addProperty($key, $value);
}