TripalWebService.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. class TripalWebService {
  3. public static $label;
  4. public static $description;
  5. public static $version;
  6. public static $name;
  7. private $context;
  8. private $response;
  9. private $supportedClasses;
  10. /**
  11. *
  12. */
  13. public function __construct() {
  14. $this->context = array();
  15. $this->response = array();
  16. $this->supportedClasses = array();
  17. $this->possibleStates = array();
  18. // First, add the RDFS and Hydra vocabularies to the context. All
  19. // web services should use these.
  20. $this->addContextItem('rdfs', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
  21. $this->addContextItem('hydra', 'http://www.w3.org/ns/hydra/core#');
  22. }
  23. public function addSupportedClass($type, $title, $description, $operations = array(), $properties = array()) {
  24. // TODO: add some checks.
  25. $this->supportedClasses[] = array(
  26. '@type' => $type,
  27. 'hydra:title' => $title,
  28. 'hydra:description' => $description,
  29. 'supportedOperation' => $operations,
  30. 'supportedProperty' => $properties,
  31. );
  32. }
  33. public function getSupportedClasses() {
  34. return $this->supportedClasses;
  35. }
  36. public function addContextItem($name, $details) {
  37. $this->context[$name] = $details;
  38. }
  39. public function getContext() {
  40. return $this->context;
  41. }
  42. public function getDocumentation() {
  43. return array(
  44. '@context' => $this->getContext(),
  45. '@id' => '',
  46. '@type' => 'ApiDocumentation',
  47. 'supportedClass' => $this->getSupportedClasses(),
  48. 'supportedStatus' => $this->getSuportedStatus(),
  49. );
  50. }
  51. }