ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilECSResult Class Reference
+ Collaboration diagram for ilECSResult:

Public Member Functions

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

Data Fields

const RESULT_TYPE_JSON = 1
 
const RESULT_TYPE_URL_LIST = 2
 

Private Member Functions

 init (string $result_string, int $result_type)
 init result (json_decode) More...
 
 parseUriList (string $a_content)
 

Private Attributes

int $http_code = 0
 
int $result_type
 
 $result
 
array $headers = array()
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

public

Parameters
stringresult_string
intresult type
Exceptions
ilECSConnectorException

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

References init().

44  {
45  $this->result_type = $a_type;
46 
47  $this->init($a_res, $a_type);
48  }
init(string $result_string, int $result_type)
init result (json_decode)
+ Here is the call graph for this function:

Member Function Documentation

◆ getHeaders()

ilECSResult::getHeaders ( )

get headers

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

99  : array
100  {
101  return $this->headers ?: [];
102  }

◆ getHTTPCode()

ilECSResult::getHTTPCode ( )

get HTTP code

public

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

References $http_code.

67  : int
68  {
69  return $this->http_code;
70  }

◆ getResult()

ilECSResult::getResult ( )

get result

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

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

References $result.

78  {
79  return $this->result;
80  }

◆ getResultType()

ilECSResult::getResultType ( )

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

References $result_type.

82  : int
83  {
84  return $this->result_type;
85  }

◆ init()

ilECSResult::init ( string  $result_string,
int  $result_type 
)
private

init result (json_decode)

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

References parseUriList().

Referenced by __construct().

107  : void
108  {
109  switch ($result_type) {
110  case self::RESULT_TYPE_JSON:
111  if ($result_string) {
112  $this->result = json_decode($result_string, false, 512, JSON_THROW_ON_ERROR);
113  } else {
114  $this->result = [];
115  }
116  break;
117 
118  case self::RESULT_TYPE_URL_LIST:
119  $this->result = $this->parseUriList($result_string);
120  break;
121  }
122  }
parseUriList(string $a_content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseUriList()

ilECSResult::parseUriList ( string  $a_content)
private
Parameters
string$a_content
Returns
ilECSUriList

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

Referenced by init().

129  : \ilECSUriList
130  {
131  $list = new ilECSUriList();
132  $lines = explode("\n", $a_content);
133  foreach ($lines as $line) {
134  $line = trim($line);
135  if ($line === '') {
136  continue;
137  }
138  $uri_parts = explode("/", $line);
139  $list->add($line, (int) array_pop($uri_parts));
140  }
141 
142  return $list;
143  }
Presentation of ecs uril (http://...campusconnect/courselinks)
+ Here is the caller graph for this function:

◆ setHeaders()

ilECSResult::setHeaders ( array  $a_headers)

Set header.

Parameters
array$a_headers

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

91  : void
92  {
93  $this->headers = $a_headers;
94  }

◆ setHTTPCode()

ilECSResult::setHTTPCode ( int  $a_code)

set HTTP return code

public

Parameters
stringhttp code

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

57  : void
58  {
59  $this->http_code = $a_code;
60  }

Field Documentation

◆ $headers

array ilECSResult::$headers = array()
private

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

◆ $http_code

int ilECSResult::$http_code = 0
private

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

Referenced by getHTTPCode().

◆ $result

ilECSResult::$result
private

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

Referenced by getResult().

◆ $result_type

int ilECSResult::$result_type
private

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

Referenced by getResultType().

◆ RESULT_TYPE_JSON

const ilECSResult::RESULT_TYPE_JSON = 1

Definition at line 25 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: