ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 getCopyDefinitions(): array
44 {
46 }
47
52 public function setCopyDefinitions(array $a_definitions): void
53 {
54 $this->copy_definitions = $a_definitions;
55 }
56
57 public function getTempDir(): string
58 {
59 return $this->temp_dir;
60 }
61
65 public function setTempDir(string $temp_dir): void
66 {
67 $this->temp_dir = $temp_dir;
68 }
69
73 public function getObjectWspIds(): array
74 {
76 }
77
78 public function setObjectWspIds(
79 array $object_wps_ids,
80 bool $append = false
81 ): void {
82 if ($append) {
83 $this->object_wsp_ids = array_merge($this->object_wsp_ids, $object_wps_ids);
84 } else {
85 $this->object_wsp_ids = $object_wps_ids;
86 }
87 }
88
89 public function getNumFiles(): int
90 {
91 return $this->num_files;
92 }
93
94 public function setNumFiles(int $num_files): void
95 {
96 $this->num_files = $num_files;
97 }
98
99 public function getSumFileSizes(): int
100 {
101 return $this->sum_file_sizes;
102 }
103
104 public function setSumFileSizes(int $sum_file_sizes): void
105 {
106 $this->sum_file_sizes = $sum_file_sizes;
107 }
108
110 {
111 return $this->adheres_to_limit;
112 }
113
114 public function setAdheresToLimit(BooleanValue $adheres_to_limit): void
115 {
116 $this->adheres_to_limit = $adheres_to_limit;
117 }
118
119 public function addCopyDefinition(string $a_source, string $a_target): void
120 {
121 $this->copy_definitions[] =
122 [
123 self::COPY_SOURCE_DIR => $a_source,
124 self::COPY_TARGET_DIR => $a_target
125 ];
126 }
127
128 public function equals(Value $other): bool
129 {
130 return strcmp($this->getHash(), $other->getHash());
131 }
132
133 public function getHash(): string
134 {
135 return md5($this->serialize());
136 }
137
138 public function serialize(): string
139 {
140 return serialize(
141 [
142 "copy_definition" => $this->getCopyDefinitions(),
143 "temp_dir" => $this->getTempDir(),
144 "object_wsp_ids" => implode(",", $this->getObjectWspIds()),
145 "num_files" => $this->getNumFiles(),
146 "sum_file_sizes" => $this->getSumFileSizes(),
147 "adheres_to_limit" => $this->getAdheresToLimit()
148 ]
149 );
150 }
151
156 public function setValue($value): void
157 {
158 $this->copy_definitions = $value;
159 }
160
165 public function unserialize($data)
166 {
167 $elements = unserialize((string) $data, ['allowed_classes' => false]);
168
169 $this->setCopyDefinitions($elements["copy_definition"]);
170 $this->setTempDir($elements['temp_dir']);
171 $this->setObjectWspIds(explode(",", $elements["object_wsp_ids"]));
172 $this->setNumFiles($elements["num_files"]);
173 $this->setSumFileSizes($elements["sum_file_sizes"]);
174 $this->setAdheresToLimit($elements["adheres_to_limit"]);
175 }
176}
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)
array $copy_definitions
Copy Jobs: source file => relative target file in zip directory.
addCopyDefinition(string $a_source, string $a_target)
unserialize($data)
Unserialize definitions.
if(!file_exists('../ilias.ini.php'))