ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCopyDefinition.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';
36 private array $copy_definitions = [];
40 private string $temp_dir;
45 private array $object_ref_ids = [];
50 private int $num_files = 0;
55 private ?int $sum_file_sizes = 0;
60
65 public function getCopyDefinitions(): array
66 {
68 }
69
74 public function setCopyDefinitions(array $a_definitions): void
75 {
76 $this->copy_definitions = $a_definitions;
77 }
78
82 public function getTempDir(): string
83 {
84 return $this->temp_dir;
85 }
86
91 public function setTempDir(string $temp_dir): void
92 {
93 $this->temp_dir = $temp_dir;
94 }
95
99 public function getObjectRefIds(): array
100 {
102 }
103
107 public function setObjectRefIds(array $object_ref_ids, bool $append = false): void
108 {
109 $this->object_ref_ids = $append ? array_merge($this->object_ref_ids, $object_ref_ids) : $object_ref_ids;
110 }
111
112 public function getNumFiles(): int
113 {
114 return $this->num_files;
115 }
116
117 public function setNumFiles(int $num_files): void
118 {
119 $this->num_files = $num_files;
120 }
121
122 public function getSumFileSizes(): int
123 {
124 return $this->sum_file_sizes ?? 0;
125 }
126
127 public function setSumFileSizes(int $sum_file_sizes): void
128 {
129 $this->sum_file_sizes = $sum_file_sizes;
130 }
131
133 {
134 $fallback = new BooleanValue();
135 $fallback->setValue(false);
136 return $this->adheres_to_limit ?? $fallback;
137 }
138
140 {
141 $this->adheres_to_limit = $adheres_to_limit;
142 }
143
144 public function addCopyDefinition(string $a_source, string $a_target): void
145 {
146 $this->copy_definitions[]
147 = [
148 self::COPY_SOURCE_DIR => $a_source,
149 self::COPY_TARGET_DIR => $a_target,
150 ];
151 }
152
156 public function equals(Value $other): bool
157 {
158 return strcmp($this->getHash(), $other->getHash());
159 }
160
164 public function getHash(): string
165 {
166 return md5($this->serialize());
167 }
168
173 public function serialize()
174 {
175 return serialize(
176 [
177 "copy_definition" => $this->getCopyDefinitions(),
178 "temp_dir" => $this->getTempDir(),
179 "object_ref_ids" => implode(",", $this->getObjectRefIds()),
180 "num_files" => $this->getNumFiles(),
181 "sum_file_sizes" => $this->getSumFileSizes(),
182 "adheres_to_limit" => $this->getAdheresToLimit(),
183 ]
184 );
185 }
186
191 public function setValue($value): void
192 {
193 $this->copy_definitions = $value;
194 }
195
200 public function unserialize($serialized): void
201 {
202 $elements = unserialize($serialized);
203
204 $this->setCopyDefinitions($elements["copy_definition"]);
205 $this->setTempDir($elements['temp_dir']);
206 $this->setObjectRefIds(explode(",", (string) $elements["object_ref_ids"]));
207 $this->setNumFiles($elements["num_files"]);
208 $this->setSumFileSizes($elements["sum_file_sizes"]);
209 $this->setAdheresToLimit($elements["adheres_to_limit"]);
210 }
211}
Description of class class.
addCopyDefinition(string $a_source, string $a_target)
serialize()
Serialize content.
setValue($value)
Set value.
unserialize($serialized)
Unserialize definitions.
setCopyDefinitions(array $a_definitions)
Set copy definitions.
BooleanValue $adheres_to_limit
States if the sum of all file sizes adheres to the global limit.
setTempDir(string $temp_dir)
Set directory name located in /temp/ directory.
getCopyDefinitions()
Get copy definitions.
setObjectRefIds(array $object_ref_ids, bool $append=false)
getTempDir()
Get directory name located in /temp/ directory.
setAdheresToLimit(BooleanValue $adheres_to_limit)
string $temp_dir
Temporary directory using the normalized title of the bucket.
setSumFileSizes(int $sum_file_sizes)
equals(Value $other)
Check equality.
setNumFiles(int $num_files)