ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilFolderXmlWriter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 private bool $add_header;
29 private int $obj_id = 0;
30 private ?ilObject $folder = null;
31
32 public function __construct(bool $a_add_header)
33 {
34 $this->add_header = $a_add_header;
36 }
37
38 public function setObjId(int $a_obj_id): void
39 {
40 $this->obj_id = $a_obj_id;
41 }
42
43 public function write(): void
44 {
45 $this->init();
46 if ($this->add_header) {
47 $this->buildHeader();
48 }
49 $this->xmlStartTag('Folder', ['Id' => $this->folder->getId()]);
50 $this->xmlElement('Title', [], $this->folder->getTitle());
51 $this->xmlElement('Description', [], $this->folder->getDescription());
53 $this->xmlEndTag('Folder');
54 }
55
56 protected function buildHeader(): void
57 {
58 $this->xmlSetGenCmt("Export of a ILIAS Folder");
59 $this->xmlHeader();
60 }
61
62 protected function init(): void
63 {
64 $this->xmlClear();
65
66 if (!$this->obj_id) {
67 throw new UnexpectedValueException('No obj_id given: ');
68 }
69 if (!$this->folder = ilObjectFactory::getInstanceByObjId($this->obj_id, false)) {
70 throw new UnexpectedValueException('Invalid obj_id given: ' . $this->obj_id);
71 }
72 if ($this->folder->getType() !== 'fold') {
73 throw new UnexpectedValueException('Invalid obj_id given. Object is not of type folder');
74 }
75 }
76}
static _exportContainerSortingSettings(ilXmlWriter $xml, int $obj_id)
sorting XML-export for all container objects
XML writer for folders.
__construct(bool $a_add_header)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObject Basic functions for all objects.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlSetGenCmt(string $genCmt)
Sets generated comment.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlClear()
clears xmlStr
xmlHeader()
Writes xml header.
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc