ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilECSResult Class Reference
+ Collaboration diagram for ilECSResult:

Public Member Functions

 __construct ($a_res, $a_type=self::RESULT_TYPE_JSON)
 Constructor. More...
 
 setHTTPCode ($a_code)
 set HTTP return code More...
 
 getHTTPCode ()
 get HTTP code More...
 
 getPlainResultString ()
 get unformated result string More...
 
 getResult ()
 get result More...
 
 setHeaders ($a_headers)
 Set header. More...
 
 getHeaders ()
 get headers More...
 

Data Fields

const RESULT_TYPE_JSON = 1
 
const RESULT_TYPE_URL_LIST = 2
 

Protected Attributes

 $log
 
 $result_string = ''
 
 $http_code = ''
 
 $result
 
 $result_type
 
 $headers = array()
 

Private Member Functions

 init ()
 init result (json_decode) private More...
 
 parseUriList ($a_content)
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 35 of file class.ilECSResult.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSResult::__construct (   $a_res,
  $a_type = self::RESULT_TYPE_JSON 
)

Constructor.

public

Parameters
stringresult_string
intresult type
Exceptions
ilECSConnectorException

Definition at line 58 of file class.ilECSResult.php.

References $DIC, and init().

59  {
60  global $DIC;
61 
62  $ilLog = $DIC['ilLog'];
63 
64  $this->log = $ilLog;
65 
66  $this->result_string = $a_res;
67  $this->result_type = $a_type;
68 
69  $this->init();
70  }
global $DIC
Definition: goto.php:24
init()
init result (json_decode) private
+ Here is the call graph for this function:

Member Function Documentation

◆ getHeaders()

ilECSResult::getHeaders ( )

get headers

public

Definition at line 131 of file class.ilECSResult.php.

132  {
133  return $this->headers ?: [];
134  }

◆ getHTTPCode()

ilECSResult::getHTTPCode ( )

get HTTP code

public

Definition at line 89 of file class.ilECSResult.php.

References $http_code.

90  {
91  return $this->http_code;
92  }

◆ getPlainResultString()

ilECSResult::getPlainResultString ( )

get unformated result string

public

Definition at line 100 of file class.ilECSResult.php.

References $result_string.

Referenced by parseUriList().

101  {
102  return $this->result_string;
103  }
+ Here is the caller graph for this function:

◆ getResult()

ilECSResult::getResult ( )

get result

public

Returns
mixed JSON object, array of objects or false in case of errors.

Definition at line 112 of file class.ilECSResult.php.

References $result.

113  {
114  return $this->result;
115  }

◆ init()

ilECSResult::init ( )
private

init result (json_decode) private

Definition at line 141 of file class.ilECSResult.php.

References parseUriList().

Referenced by __construct().

142  {
143  switch ($this->result_type) {
144  case self::RESULT_TYPE_JSON:
145  if ($this->result_string) {
146  $this->result = json_decode($this->result_string);
147  } else {
148  $this->result = array();
149  }
150  break;
151 
152  case self::RESULT_TYPE_URL_LIST:
153  $this->result = $this->parseUriList($this->result_string);
154  break;
155  }
156  return true;
157  }
parseUriList($a_content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseUriList()

ilECSResult::parseUriList (   $a_content)
private
Parameters
<type>$a_content
Returns
ilECSUriList

Definition at line 164 of file class.ilECSResult.php.

References getPlainResultString().

Referenced by init().

165  {
166  include_once 'Services/WebServices/ECS/classes/class.ilECSUriList.php';
167  $list = new ilECSUriList();
168  $lines = explode("\n", $this->getPlainResultString());
169  foreach ($lines as $line) {
170  $line = trim($line);
171  if (!strlen($line)) {
172  continue;
173  }
174  $uri_parts = explode("/", $line);
175  $list->add($line, array_pop($uri_parts));
176  }
177 
178  return $list;
179  }
Presentation of ecs uril (http://...campusconnect/courselinks)
getPlainResultString()
get unformated result string
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHeaders()

ilECSResult::setHeaders (   $a_headers)

Set header.

Parameters
array$a_headers

Definition at line 121 of file class.ilECSResult.php.

122  {
123  $this->headers = $a_headers;
124  }

◆ setHTTPCode()

ilECSResult::setHTTPCode (   $a_code)

set HTTP return code

public

Parameters
stringhttp code

Definition at line 79 of file class.ilECSResult.php.

80  {
81  $this->http_code = $a_code;
82  }

Field Documentation

◆ $headers

ilECSResult::$headers = array()
protected

Definition at line 47 of file class.ilECSResult.php.

◆ $http_code

ilECSResult::$http_code = ''
protected

Definition at line 43 of file class.ilECSResult.php.

Referenced by getHTTPCode().

◆ $log

ilECSResult::$log
protected

Definition at line 40 of file class.ilECSResult.php.

◆ $result

ilECSResult::$result
protected

Definition at line 44 of file class.ilECSResult.php.

Referenced by getResult().

◆ $result_string

ilECSResult::$result_string = ''
protected

Definition at line 42 of file class.ilECSResult.php.

Referenced by getPlainResultString().

◆ $result_type

ilECSResult::$result_type
protected

Definition at line 45 of file class.ilECSResult.php.

◆ RESULT_TYPE_JSON

const ilECSResult::RESULT_TYPE_JSON = 1

Definition at line 37 of file class.ilECSResult.php.

◆ RESULT_TYPE_URL_LIST

const ilECSResult::RESULT_TYPE_URL_LIST = 2

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