ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
class.ilWorkspaceCopyDefinition.php
Go to the documentation of this file.
1<?php
2
22
28{
29 public const COPY_SOURCE_DIR = 'source';
30 public const COPY_TARGET_DIR = 'target';
31
36 private array $copy_definitions = [];
37 private string $temp_dir;
38 private array $object_wsp_ids = [];
39 private int $num_files = 0;
40 private int $sum_file_sizes = 0;
42
43 public function __construct()
44 {
47 $this->adheres_to_limit = $adheres_to_limit;
48 }
49
50 public function getCopyDefinitions(): array
51 {
53 }
54
59 public function setCopyDefinitions(array $a_definitions): void
60 {
61 $this->copy_definitions = $a_definitions;
62 }
63
64 public function getTempDir(): string
65 {
66 return $this->temp_dir;
67 }
68
72 public function setTempDir(string $temp_dir): void
73 {
74 $this->temp_dir = $temp_dir;
75 }
76
80 public function getObjectWspIds(): array
81 {
83 }
84
85 public function setObjectWspIds(
86 array $object_wps_ids,
87 bool $append = false
88 ): void {
89 if ($append) {
90 $this->object_wsp_ids = array_merge($this->object_wsp_ids, $object_wps_ids);
91 } else {
92 $this->object_wsp_ids = $object_wps_ids;
93 }
94 }
95
96 public function getNumFiles(): int
97 {
98 return $this->num_files;
99 }
100
101 public function setNumFiles(int $num_files): void
102 {
103 $this->num_files = $num_files;
104 }
105
106 public function getSumFileSizes(): int
107 {
108 return $this->sum_file_sizes;
109 }
110
111 public function setSumFileSizes(int $sum_file_sizes): void
112 {
113 $this->sum_file_sizes = $sum_file_sizes;
114 }
115
117 {
118 return $this->adheres_to_limit;
119 }
120
121 public function setAdheresToLimit(BooleanValue $adheres_to_limit): void
122 {
123 $this->adheres_to_limit = $adheres_to_limit;
124 }
125
126 public function addCopyDefinition(string $a_source, string $a_target): void
127 {
128 $this->copy_definitions[] =
129 [
130 self::COPY_SOURCE_DIR => $a_source,
131 self::COPY_TARGET_DIR => $a_target
132 ];
133 }
134
135 public function equals(Value $other): bool
136 {
137 return strcmp($this->getHash(), $other->getHash());
138 }
139
140 public function getHash(): string
141 {
142 return md5($this->serialize());
143 }
144
145 public function serialize(): string
146 {
147 return serialize(
148 [
149 "copy_definition" => $this->getCopyDefinitions(),
150 "temp_dir" => $this->getTempDir(),
151 "object_wsp_ids" => implode(",", $this->getObjectWspIds()),
152 "num_files" => $this->getNumFiles(),
153 "sum_file_sizes" => $this->getSumFileSizes(),
154 "adheres_to_limit" => $this->getAdheresToLimit()
155 ]
156 );
157 }
158
163 public function setValue($value): void
164 {
165 $this->copy_definitions = $value;
166 }
167
172 public function unserialize(?string $data): void
173 {
174 $elements = unserialize((string) $data, ['allowed_classes' => false]);
175
176 $this->setCopyDefinitions($elements["copy_definition"]);
177 $this->setTempDir($elements['temp_dir']);
178 $this->setObjectWspIds(explode(",", $elements["object_wsp_ids"]));
179 $this->setNumFiles($elements["num_files"]);
180 $this->setSumFileSizes($elements["sum_file_sizes"]);
181 $this->setAdheresToLimit($elements["adheres_to_limit"]);
182 }
183}
Copy definition for workspace folders.
setTempDir(string $temp_dir)
Set directory name located in /temp/ directory.
setObjectWspIds(array $object_wps_ids, bool $append=false)
setCopyDefinitions(array $a_definitions)
Set copy definitions.
setAdheresToLimit(BooleanValue $adheres_to_limit)
unserialize(?string $data)
Unserialize definitions.
array $copy_definitions
Copy Jobs: source file => relative target file in zip directory.
addCopyDefinition(string $a_source, string $a_target)
if(!file_exists('../ilias.ini.php'))