◆ __construct()
| ilScormImportParser::__construct |
( |
DataTypeFactory |
$data_factory | ) |
|
◆ addErrors()
| ilScormImportParser::addErrors |
( |
| ) |
|
|
private |
Definition at line 68 of file class.ilScormImportParser.php.
Referenced by beginLogging(), and endLogging().
70 $currentErrors = libxml_get_errors();
71 libxml_clear_errors();
73 $level = count($this->error_stack) - 1;
74 $this->error_stack[$level] = array_merge($this->error_stack[$level], $currentErrors);
◆ beginLogging()
| ilScormImportParser::beginLogging |
( |
| ) |
|
|
private |
Definition at line 56 of file class.ilScormImportParser.php.
References addErrors().
Referenced by parse().
58 if ([] === $this->error_stack) {
59 $this->xml_error_state = libxml_use_internal_errors(
true);
60 libxml_clear_errors();
65 $this->error_stack[] = [];
◆ 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.
References addErrors().
Referenced by parse().
84 $errors = array_pop($this->error_stack);
86 if ([] === $this->error_stack) {
87 libxml_use_internal_errors($this->xml_error_state);
◆ formatError()
| ilScormImportParser::formatError |
( |
LibXMLError |
$error | ) |
|
|
private |
Definition at line 35 of file class.ilScormImportParser.php.
Referenced by formatErrors().
38 'level=' . $error->level,
39 'code=' . $error->code,
40 'line=' . $error->line,
41 'col=' . $error->column,
42 'msg=' . trim($error->message)
◆ formatErrors()
| ilScormImportParser::formatErrors |
( |
LibXMLError ... |
$errors | ) |
|
|
private |
◆ parse()
| ilScormImportParser::parse |
( |
string |
$xmlString | ) |
|
Definition at line 93 of file class.ilScormImportParser.php.
References Vendor\Package\$e, beginLogging(), endLogging(), and formatErrors().
98 $xml =
new SimpleXMLElement($xmlString);
102 if ($xml->xpath(
'//SubType')) {
103 return $this->df->ok($xml);
107 $error->level = LIBXML_ERR_FATAL;
109 $error->message =
'No "SubType" element found';
115 return $this->df->error($this->
formatErrors(...$errors));
A result encapsulates a value or an error and simplifies the handling of those.
formatErrors(LibXMLError ... $errors)
◆ $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: