ILIAS  release_8 Revision v8.24
class.ilECSCourseConnector.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
24{
29 public function getCourse($course_id, $a_details = false)
30 {
31 $this->path_postfix = '/campusconnect/courses/' . (int) $course_id;
32
33 if ($a_details && $course_id) {
34 $this->path_postfix .= '/details';
35 }
36
37 try {
38 $this->prepareConnection();
39 $this->setHeader([]);
40 if ($a_details) {
41 $this->addHeader('Accept', 'application/json');
42 } else {
43 $this->addHeader('Accept', 'text/uri-list');
44 }
45 $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
46 $res = $this->call();
47
48 if (strpos($res, 'http') === 0) {
49 $json = file_get_contents($res);
50 $ecs_result = new ilECSResult($json);
51 } else {
52 $ecs_result = new ilECSResult($res);
53 }
54
55 // Return ECSEContentDetails for details switch
56 if ($a_details) {
58 $details->loadFromJson($ecs_result->getResult());
59 return $details;
60 }
61 // Return json result
62 return $ecs_result->getResult();
64 $this->logger->error('Error calling ECS service: ' . $e->getMessage());
65 throw new ilECSConnectorException('Error calling ECS service: ' . $e->getMessage());
66 }
67 }
68}
addHeader(string $a_name, string $a_value)
Add Header.
prepareConnection()
prepare connection
setHeader(array $a_header_strings)
getCourse($course_id, $a_details=false)
Get single directory tree.
Presentation of ecs content details (http://...campusconnect/courselinks/id/details)
$res
Definition: ltiservices.php:69
array $details
Details for error message relating to last request processed.
Definition: System.php:109