ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
ILIAS\Conditions\Export\XMLWriter Class Reference
+ Collaboration diagram for ILIAS\Conditions\Export\XMLWriter:

Public Member Functions

 __construct ()
 
 write (Info $info)
 
 writeAll (InfoCollection $infos)
 
 __toString ()
 

Protected Attributes

SimpleXMLElement $xml_root
 

Detailed Description

Definition at line 27 of file XMLWriter.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Conditions\Export\XMLWriter::__construct ( )

Definition at line 30 of file XMLWriter.php.

31 {
32 $this->xml_root = new SimpleXMLElement('<Conditions></Conditions>');
33 }

Member Function Documentation

◆ __toString()

ILIAS\Conditions\Export\XMLWriter::__toString ( )

Definition at line 67 of file XMLWriter.php.

67 : string
68 {
69 return trim(str_replace('<?xml version="1.0"?>', '', $this->xml_root->asXML()));
70 }

◆ write()

ILIAS\Conditions\Export\XMLWriter::write ( Info  $info)

Definition at line 35 of file XMLWriter.php.

37 : void {
38 $cond_xml = $this->xml_root->addChild('Condition');
39 $cond_xml->addAttribute('object_id', (string) $info->getObjectId());
40 $cond_xml->addAttribute('reference_id', (string) $info->getReferenceId());
41 $cond_xml->addAttribute('object_type', $info->getObjectType());
42 $cond_xml->addAttribute('hide_object_enabled', (string) ((int) $info->getConditionSet()->getHiddenStatus()));
43 $cond_xml->addAttribute('all_obligatory_enabled', (string) ((int) $info->getConditionSet()->getAllObligatory()));
44 $cond_xml->addAttribute('number_of_required_materials', (string) $info->getConditionSet()->getNumObligatory());
45 $p_conds_xml = $cond_xml->addChild('Preconditions');
46 foreach ($info->getConditionSet()->getConditions() as $precondition) {
47 $p_cond_xml = $p_conds_xml->addChild('Precondition');
48 $p_cond_xml->addAttribute('id', (string) $precondition->getId());
49 $p_cond_xml->addAttribute('is_obligatory', (string) ((int) $precondition->getObligatory()));
50 $p_cond_xml->addAttribute('operator', $precondition->getOperator());
51 $p_cond_xml->addAttribute('value', $precondition->getValue() ?? '');
52 $p_cond_trigger_xml = $p_cond_xml->addChild('Trigger');
53 $p_cond_trigger_xml->addAttribute('ref_id', (string) $precondition->getTrigger()->getRefId());
54 $p_cond_trigger_xml->addAttribute('obj_id', (string) $precondition->getTrigger()->getObjId());
55 $p_cond_trigger_xml->addAttribute('type', $precondition->getTrigger()->getType());
56 }
57 }
$info
Definition: entry_point.php:21

◆ writeAll()

ILIAS\Conditions\Export\XMLWriter::writeAll ( InfoCollection  $infos)

Definition at line 59 of file XMLWriter.php.

61 : void {
62 foreach ($infos as $info) {
63 $this->write($info);
64 }
65 }

References $info.

Field Documentation

◆ $xml_root

SimpleXMLElement ILIAS\Conditions\Export\XMLWriter::$xml_root
protected

Definition at line 29 of file XMLWriter.php.


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