private function TripalWebService::generateDocClassProp

3.x TripalWebService.inc private TripalWebService::generateDocClassProp($supported_class, $prop)

A helper function for the addClass() function for generating a property.

1 call to TripalWebService::generateDocClassProp()
TripalWebService::addDocClass in tripal_ws/includes/TripalWebService.inc
Defines an entity class for the web services.

File

tripal_ws/includes/TripalWebService.inc, line 467

Class

TripalWebService

Code

private function generateDocClassProp($supported_class, $prop) {
  $supported_class->addContextItem('property', array(
    "@id" => "hydra:property",
    "@type" => "@id"
  ));
  $supported_class->addContextItem('domain', array(
    "@id" => "rdfs:domain",
    "@type" => "@id"
  ));
  $supported_class->addContextItem('range', array(
    "@id" => "rdfs:range",
    "@type" => "@id"
  ));
  $supported_class->addContextItem('readable', 'hydra:readable');
  $supported_class->addContextItem('writeable', 'hydra:writeable');
  $supported_class->addContextItem('required', 'hydra:required');
  $supported_class->addContextItem('tripal_formatters', 'tripal:tripal_formatters');
  $class_prop = array(
    'property' => $prop['type'],
    'hydra:title' => $prop['title'],
    'hydra:description' => array_key_exists('description', $prop) ? $prop['description'] : NULL,
    'required' => array_key_exists('required', $prop) ? $prop['required'] : NULL,
    'readable' => array_key_exists('readonly', $prop) ? $prop['readonly'] : NULL,
    'writeable' => array_key_exists('writeonly', $prop) ? $prop['writeonly'] : NULL,
  );
  if (array_key_exists('domain', $prop)) {
    $class_prop['domain'] = $prop['domain'];
  }
  if (array_key_exists('range', $prop)) {
    $class_prop['range'] = $prop['range'];
  }
  if (array_key_exists('operations', $prop)) {
    $class_prop['supportedOperation'] = array();
    foreach ($prop['operations'] as $op => $op_details) {
      $class_prop['supportedOperation'][] = $this->generateOp($supported_class, $op, $op_details);
    }
  }
  if (array_key_exists('tripal_formatters', $prop)) {
    $class_prop['tripal_formatters'] = array_keys($prop['tripal_formatters']);
  }
  return $class_prop;
}