ILIAS  release_8 Revision v8.24
class.ilECSDirectoryTreeConnector.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
27{
32 public function getDirectoryTrees(int $a_mid = 0): ?\ilECSUriList
33 {
34 $this->path_postfix = '/campusconnect/directory_trees';
35
36 try {
37 $this->prepareConnection();
38 $this->setHeader(array());
39 $this->addHeader('Accept', 'text/uri-list');
40 $this->addHeader('X-EcsQueryStrings', 'all=true');
41 if ($a_mid) {
42 $this->addHeader('X-EcsReceiverMemberships', (string) $a_mid);
43 }
44
45 $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
46 $res = $this->call();
47
48 return (new ilECSResult($res, ilECSResult::RESULT_TYPE_URL_LIST))->getResult();
49 } catch (ilCurlConnectionException $exc) {
50 throw new ilECSConnectorException('Error calling ECS service: ' . $exc->getMessage());
51 }
52 }
53
58 public function getDirectoryTree($tree_id): ilECSResult
59 {
60 $this->path_postfix = '/campusconnect/directory_trees/' . (int) $tree_id;
61
62 try {
63 $this->prepareConnection();
64 $this->setHeader(array());
65 $this->addHeader('Accept', 'text/uri-list');
66 $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
67 $res = $this->call();
68
69 if (strpos($res, 'http') === 0) {
70 $json = file_get_contents($res);
71 $ecs_result = new ilECSResult($json);
72 } else {
73 $ecs_result = new ilECSResult($res);
74 }
75 return $ecs_result;
77 throw new ilECSConnectorException('Error calling ECS service: ' . $e->getMessage());
78 }
79 }
80}
addHeader(string $a_name, string $a_value)
Add Header.
prepareConnection()
prepare connection
setHeader(array $a_header_strings)
getDirectoryTree($tree_id)
Get single directory tree.
getDirectoryTrees(int $a_mid=0)
Get directory tree.
const RESULT_TYPE_URL_LIST
Presentation of ecs uril (http://...campusconnect/courselinks)
$res
Definition: ltiservices.php:69