◆ __construct()
ilScormImportParser::__construct |
( |
DataTypeFactory |
$data_factory | ) |
|
◆ addErrors()
ilScormImportParser::addErrors |
( |
| ) |
|
|
private |
Definition at line 68 of file class.ilScormImportParser.php.
68 : void
69 {
70 $currentErrors = libxml_get_errors();
71 libxml_clear_errors();
72
73 $level = count($this->error_stack) - 1;
74 $this->error_stack[$level] = array_merge($this->error_stack[$level], $currentErrors);
75 }
Referenced by beginLogging(), and endLogging().
◆ beginLogging()
ilScormImportParser::beginLogging |
( |
| ) |
|
|
private |
Definition at line 56 of file class.ilScormImportParser.php.
56 : void
57 {
58 if ([] === $this->error_stack) {
59 $this->xml_error_state = libxml_use_internal_errors(true);
60 libxml_clear_errors();
61 } else {
63 }
64
65 $this->error_stack[] = [];
66 }
References addErrors().
Referenced by parse().
◆ endLogging()
ilScormImportParser::endLogging |
( |
| ) |
|
|
private |
- Returns
- LibXMLError[] An array with the LibXMLErrors which has occurred since beginLogging() was called.
Definition at line 80 of file class.ilScormImportParser.php.
80 : array
81 {
83
84 $errors = array_pop($this->error_stack);
85
86 if ([] === $this->error_stack) {
87 libxml_use_internal_errors($this->xml_error_state);
88 }
89
90 return $errors;
91 }
References addErrors().
Referenced by parse().
◆ formatError()
ilScormImportParser::formatError |
( |
LibXMLError |
$error | ) |
|
|
private |
Definition at line 35 of file class.ilScormImportParser.php.
35 : string
36 {
37 return implode(',', [
38 'level=' . $error->level,
39 'code=' . $error->code,
40 'line=' . $error->line,
41 'col=' . $error->column,
42 'msg=' . trim($error->message)
43 ]);
44 }
Referenced by formatErrors().
◆ formatErrors()
ilScormImportParser::formatErrors |
( |
LibXMLError ... |
$errors | ) |
|
|
private |
◆ parse()
ilScormImportParser::parse |
( |
string |
$xmlString | ) |
|
Definition at line 93 of file class.ilScormImportParser.php.
94 {
95 try {
97
98 $xml = new SimpleXMLElement($xmlString);
99
101
102 if ($xml->xpath('//SubType')) {
103 return $this->df->ok($xml);
104 }
105
106 $error = new LibXMLError();
107 $error->level = LIBXML_ERR_FATAL;
108 $error->code = 0;
109 $error->message = 'No "SubType" element found';
110 $error->line = 1;
111 $error->column = 0;
112
113 $errors[] = $error;
114
115 return $this->df->error($this->
formatErrors(...$errors));
116 }
catch (Throwable
$e) {
118 }
119 }
formatErrors(LibXMLError ... $errors)
A result encapsulates a value or an error and simplifies the handling of those.
References Vendor\Package\$e, beginLogging(), endLogging(), and formatErrors().
◆ $df
DataTypeFactory ilScormImportParser::$df |
|
private |
◆ $error_stack
array ilScormImportParser::$error_stack = [] |
|
private |
◆ $xml_error_state
bool ilScormImportParser::$xml_error_state = false |
|
private |
The documentation for this class was generated from the following file: