ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilECSCourseUrlConnector Class Reference

Connector for writing ecs course urls. More...

+ Inheritance diagram for ilECSCourseUrlConnector:
+ Collaboration diagram for ilECSCourseUrlConnector:

Public Member Functions

 addUrl (ilECSCourseUrl $url, $a_target_mid)
 Send url of newly created courses to ecs. More...
 
- Public Member Functions inherited from ilECSConnector
 __construct (?ilECSSetting $settings=null)
 
 addHeader (string $a_name, string $a_value)
 Add Header. More...
 
 getHeader ()
 
 setHeader (array $a_header_strings)
 
 getServer ()
 Get current server setting. More...
 
 addAuth (string $a_post, int $a_target_mid)
 Add auth resource. More...
 
 getAuth (string $a_hash, bool $a_details_only=false)
 get auth resource More...
 
 readEventFifo (bool $a_delete=false)
 Read event fifo. More...
 
 getResourceList (string $a_path)
 
 getResource (string $a_path, int $a_econtent_id, bool $a_details_only=false)
 Get resources from ECS server. More...
 
 addResource (string $a_path, $a_post)
 Add resource. More...
 
 updateResource (string $a_path, int $a_econtent_id, string $a_post_string)
 update resource More...
 
 deleteResource (string $a_path, int $a_econtent_id)
 Delete resource. More...
 
 getMemberships (int $a_mid=0)
 

Additional Inherited Members

- Data Fields inherited from ilECSConnector
const HTTP_CODE_CREATED = 201
 
const HTTP_CODE_OK = 200
 
const HTTP_CODE_NOT_FOUND = 404
 
const HEADER_MEMBERSHIPS = 'X-EcsReceiverMemberships'
 
const HEADER_COMMUNITIES = 'X-EcsReceiverCommunities'
 
- Protected Member Functions inherited from ilECSConnector
 prepareConnection ()
 prepare connection More...
 
 call ()
 call peer More...
 
- Protected Attributes inherited from ilECSConnector
string $path_postfix = ''
 
ilECSSetting $settings = null
 
ilCurlConnection $curl = null
 
array $header_strings = []
 
ilLogger $logger
 

Detailed Description

Connector for writing ecs course urls.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 26 of file class.ilECSCourseUrlConnector.php.

Member Function Documentation

◆ addUrl()

ilECSCourseUrlConnector::addUrl ( ilECSCourseUrl  $url,
  $a_target_mid 
)

Send url of newly created courses to ecs.

Exceptions
ilECSConnectorException

Definition at line 32 of file class.ilECSCourseUrlConnector.php.

References ilECSConnector\addHeader(), ilECSConnector\call(), ilECSConnector\getHeader(), ilECSConnector\HEADER_MEMBERSHIPS, ILIAS\Repository\logger(), and ilECSConnector\prepareConnection().

32  : void
33  {
34  $this->logger->info(__METHOD__ . ': Add new course url ...');
35 
36  $this->path_postfix = '/campusconnect/course_urls';
37 
38  try {
39  $this->prepareConnection();
40 
41  $this->addHeader('Content-Type', 'application/json');
42  $this->addHeader('Accept', 'application/json');
43  $this->addHeader(ilECSConnector::HEADER_MEMBERSHIPS, (string) $a_target_mid);
44 
45  $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
46  $this->curl->setOpt(CURLOPT_POST, true);
47  $this->curl->setOpt(CURLOPT_POSTFIELDS, json_encode($url, JSON_THROW_ON_ERROR));
48 
49  $this->logger->debug('Sending url ' . print_r(json_encode($url, JSON_THROW_ON_ERROR), true));
50 
51  $this->call();
52 
53  $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
54 
55  $this->logger->debug('Checking HTTP status...');
56  if ($info !== self::HTTP_CODE_CREATED) {
57  $this->logger->debug('Cannot create course url ressource, did not receive HTTP 201. ');
58  $this->logger->debug('POST was: ' . json_encode($url, JSON_THROW_ON_ERROR));
59  $this->logger->debug('HTTP code: ' . $info);
60  throw new ilECSConnectorException('Received HTTP status code: ' . $info);
61  }
62  $this->logger->debug('... got HTTP 201 (created)');
63  //TODO add returning of the new created courseurl id
64  } catch (ilCurlConnectionException $exc) {
65  throw new ilECSConnectorException('Error calling ECS service: ' . $exc->getMessage());
66  }
67  }
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
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: