ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ExportCollector.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 
27 {
28  protected string $rid = "";
29 
30  public function __construct(
31  protected DataService $data,
32  protected ExportFileDBRepository $repo,
33  protected int $obj_id,
34  protected string $type = ""
35  ) {
36  }
37 
41  public function init(string $zipname = ""): string
42  {
43  if ($this->rid !== "") {
44  throw $this->data->exportException("HTML Export has been initialised twice.");
45  }
46  if ($zipname === "") {
47  $date = time();
48  $zipname = $date . "__" . IL_INST_ID . "__" .
49  \ilObject::_lookupType($this->obj_id) . "_" . $this->obj_id . ".zip";
50  }
51  $this->rid = $this->repo->create(
52  $this->obj_id,
53  $this->type,
54  $zipname
55  );
56 
57  //$this->repo->rename($this->rid, $zipname);
58 
59  return $this->rid;
60  }
61 
65  public function addString(
66  string $content,
67  string $path
68  ): void {
69  if ($this->rid === "") {
70  throw $this->data->exportException("HTML Export has not been initialised.");
71  }
72  $this->repo->addString(
73  $this->rid,
74  $content,
75  $path
76  );
77  }
78 
82  public function addFile(
83  string $fullpath,
84  string $target_path
85  ): void {
86  if ($this->rid === "") {
87  throw $this->data->exportException("HTML Export has not been initialised.");
88  }
89  $this->repo->addFile(
90  $this->rid,
91  $fullpath,
92  $target_path
93  );
94  }
95 
99  public function addDirectory(
100  string $source_dir,
101  string $target_path
102  ): void {
103  if ($this->rid === "") {
104  throw $this->data->exportException("HTML Export has not been initialised.");
105  }
106  $this->repo->addDirectory(
107  $this->rid,
108  $source_dir,
109  $target_path
110  );
111  }
112 
113  public function addContainerDirectory(
114  string $source_container_id,
115  string $source_dir_path = "",
116  string $target_dir_path = ""
117  ): void {
118  if ($this->rid === "") {
119  throw $this->data->exportException("HTML Export has not been initialised.");
120  }
121  $this->repo->addContainerDirToTargetContainer(
122  $source_container_id,
123  $this->rid,
124  $source_dir_path,
125  $target_dir_path
126  );
127  }
128 
129  public function getFilePath(): string
130  {
131  return $this->repo->getFilePath($this->rid);
132  }
133 
134  public function deliver(string $filename): void
135  {
136  $this->repo->deliverFile($this->rid);
137  }
138 
139  public function delete(): void
140  {
141  $this->repo->delete($this->obj_id, $this->rid);
142  }
143 
144 }
const IL_INST_ID
Definition: constants.php:40
$path
Definition: ltiservices.php:29
addFile(string $fullpath, string $target_path)
addDirectory(string $source_dir, string $target_path)
addContainerDirectory(string $source_container_id, string $source_dir_path="", string $target_dir_path="")
$filename
Definition: buildRTE.php:78
__construct(protected DataService $data, protected ExportFileDBRepository $repo, protected int $obj_id, protected string $type="")
static _lookupType(int $id, bool $reference=false)
addString(string $content, string $path)