protected function TripalWebService::addContextVocab

3.x TripalWebService.inc protected TripalWebService::addContextVocab($resource, $vocab)

Adds a vocabulary to the '@context' section for a given resource.

Parameters

$resource: A TripalWebServiceResource instance.

$vocab: The vocabulary array.

1 call to TripalWebService::addContextVocab()
TripalWebService::addContextTerm in tripal_ws/includes/TripalWebService.inc
Adds a term to the '@context' section for a given resource.

File

tripal_ws/includes/TripalWebService.inc, line 672

Class

TripalWebService

Code

protected function addContextVocab($resource, $vocab) {

  if (!is_a($resource, 'TripalWebServiceResource')) {
    throw new Exception('addContextVocab: Please provide a $resource of type TripalWebServiceResource.');
  }

  $key = $vocab['short_name'];
  // The URL here should be the URL prefix not the database home
  // page.  But unfortunately, the URL prefix can't be guaranteed to be
  // a true prefix. Not all databases place by the rules.  For this reason,
  // we can never use JSON-LD compact IRIs. :-(
  $iri = $vocab['sw_url'];
  $resource->addContextItem($key, $iri);
}