ILIAS  release_8 Revision v8.24
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.

@access public

Parameters
stringresult_string
intresult type
Exceptions
ilECSConnectorException

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

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)

References init().

+ 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

@access public

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

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

References $http_code.

◆ 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.

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

References $result.

◆ getResultType()

ilECSResult::getResultType ( )

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

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

References $result_type.

◆ init()

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

init result (json_decode)

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

107 : void
108 {
109 switch ($result_type) {
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
119 $this->result = $this->parseUriList($result_string);
120 break;
121 }
122 }
const RESULT_TYPE_URL_LIST
parseUriList(string $a_content)

References $result_type, parseUriList(), RESULT_TYPE_JSON, and RESULT_TYPE_URL_LIST.

Referenced by __construct().

+ 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.

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)

Referenced by init().

+ 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

@access 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(), and init().

◆ RESULT_TYPE_JSON

const ilECSResult::RESULT_TYPE_JSON = 1

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

Referenced by init().

◆ RESULT_TYPE_URL_LIST

const ilECSResult::RESULT_TYPE_URL_LIST = 2

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