public function TripalWebService::setResourceType

3.x TripalWebService.inc public TripalWebService::setResourceType($resource, $term, $sanitize = array('spacing'))

Sets the type for the given resource.

The type exist in the context of the web service.

Parameters

$resource: A TripalWebServiceResource instance.

$type: The type

$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.

4 calls to TripalWebService::setResourceType()
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::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.
TripalContentService_v0_1::doExpandedField in tripal_ws/includes/TripalWebService/TripalContentService_v0_1.inc
Creates a resource for an expanded field of an entity.

File

tripal_ws/includes/TripalWebService.inc, line 730

Class

TripalWebService

Code

public function setResourceType($resource, $term, $sanitize = array('spacing')) {

  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 set the type
  $resource->setType($key);
}