ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilECSCourseConnector.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
30  public function getCourse($course_id, $a_details = false)
31  {
32  $this->path_postfix = '/campusconnect/courses/' . (int) $course_id;
33 
34  if ($a_details && $course_id) {
35  $this->path_postfix .= '/details';
36  }
37 
38  try {
39  $this->prepareConnection();
40  $this->setHeader([]);
41  if ($a_details) {
42  $this->addHeader('Accept', 'application/json');
43  } else {
44  $this->addHeader('Accept', 'text/uri-list');
45  }
46  $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
47  $res = $this->call();
48 
49  if (strpos($res, 'http') === 0) {
50  $json = file_get_contents($res);
51  $ecs_result = new ilECSResult($json);
52  } else {
53  $ecs_result = new ilECSResult($res);
54  }
55 
56  // Return ECSEContentDetails for details switch
57  if ($a_details) {
58  $details = new ilECSEContentDetails();
59  $details->loadFromJson($ecs_result->getResult());
60  return $details;
61  }
62  // Return json result
63  return $ecs_result->getResult();
64  } catch (ilCurlConnectionException $e) {
65  $this->logger->error('Error calling ECS service: ' . $e->getMessage());
66  throw new ilECSConnectorException('Error calling ECS service: ' . $e->getMessage());
67  }
68  }
69 }
$res
Definition: ltiservices.php:66
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addHeader(string $a_name, string $a_value)
Add Header.
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
setHeader(array $a_header_strings)
prepareConnection()
prepare connection
getCourse($course_id, $a_details=false)
Get single directory tree.