ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables 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, int $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 25 of file class.ilECSCourseUrlConnector.php.

Member Function Documentation

◆ addUrl()

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

Send url of newly created courses to ecs.

Exceptions
ilECSConnectorException

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

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

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