ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCalendarRessourceStorageCopyDefinition.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
25{
26 public const COPY_RESSOURCE_ID = 'ressource_id';
27 public const COPY_ABSOLUTE_PATH = 'absolute_path';
28 public const COPY_TARGET_DIR = 'target';
29
30 private array $copy_definitions = [];
31
36 private string $temp_dir;
37
42 public function getCopyDefinitions(): array
43 {
45 }
46
51 public function setCopyDefinitions(array $a_definitions): void
52 {
53 $this->copy_definitions = $a_definitions;
54 }
55
60 public function getTempDir(): string
61 {
62 return $this->temp_dir;
63 }
64
69 public function setTempDir(string $temp_dir): void
70 {
71 $this->temp_dir = $temp_dir;
72 }
73
77 public function addCopyDefinition(string $a_path, string $a_target): void
78 {
79 $this->copy_definitions[] =
80 [
81 self::COPY_RESSOURCE_ID => null,
82 self::COPY_ABSOLUTE_PATH => $a_path,
83 self::COPY_TARGET_DIR => $a_target
84 ];
85 }
86
87 public function addCopyDefinitionRId(string $a_ressource_id, string $a_target): void
88 {
89 $this->copy_definitions[] =
90 [
91 self::COPY_RESSOURCE_ID => $a_ressource_id,
92 self::COPY_ABSOLUTE_PATH => null,
93 self::COPY_TARGET_DIR => $a_target
94 ];
95 }
96
100 public function equals(Value $other): bool
101 {
102 return strcmp($this->getHash(), $other->getHash()) === 0;
103 }
104
108 public function getHash(): string
109 {
110 return md5($this->serialize());
111 }
112
116 public function serialize()
117 {
118 return serialize(
119 [
120 "copy_definition" => $this->getCopyDefinitions(),
121 "temp_dir" => $this->getTempDir()
122 ]
123 );
124 }
125
129 public function setValue($value): void
130 {
131 $this->copy_definitions = $value;
132 }
133
137 public function unserialize($data)
138 {
139 $elements = unserialize($data);
140
141 $this->setCopyDefinitions($elements["copy_definition"]);
142 $this->setTempDir($elements['temp_dir']);
143 }
144}
addCopyDefinition(string $a_path, string $a_target)
Add copy definition.
getTempDir()
Get directory name located in /temp/ directory.
setTempDir(string $temp_dir)
Set directory name located in /temp/ directory.