ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilECSDirectoryTreeConnector.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
33 public function getDirectoryTrees(int $a_mid = 0): ?\ilECSUriList
34 {
35 $this->path_postfix = '/campusconnect/directory_trees';
36
37 try {
38 $this->prepareConnection();
39 $this->setHeader(array());
40 $this->addHeader('Accept', 'text/uri-list');
41 $this->addHeader('X-EcsQueryStrings', 'all=true');
42 if ($a_mid) {
43 $this->addHeader('X-EcsReceiverMemberships', (string) $a_mid);
44 }
45
46 $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
47 $res = $this->call();
48
49 return (new ilECSResult($res, ilECSResult::RESULT_TYPE_URL_LIST))->getResult();
50 } catch (ilCurlConnectionException $exc) {
51 throw new ilECSConnectorException('Error calling ECS service: ' . $exc->getMessage());
52 }
53 }
54
59 public function getDirectoryTree($tree_id): ilECSResult
60 {
61 $this->path_postfix = '/campusconnect/directory_trees/' . (int) $tree_id;
62
63 try {
64 $this->prepareConnection();
65 $this->setHeader(array());
66 $this->addHeader('Accept', 'text/uri-list');
67 $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
68 $res = $this->call();
69
70 if (strpos($res, 'http') === 0) {
71 $json = file_get_contents($res);
72 $ecs_result = new ilECSResult($json);
73 } else {
74 $ecs_result = new ilECSResult($res);
75 }
76 return $ecs_result;
78 throw new ilECSConnectorException('Error calling ECS service: ' . $e->getMessage());
79 }
80 }
81}
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.
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