ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilADTInternalLink.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected ?int $value;
24
25 protected ilTree $tree;
26
27 public function __construct(ilADTDefinition $a_def)
28 {
29 global $DIC;
30 parent::__construct($a_def);
31
32 $this->tree = $DIC->repositoryTree();
33 }
34
39 protected function isValidDefinition(ilADTDefinition $a_def): bool
40 {
41 return $a_def instanceof ilADTInternalLinkDefinition;
42 }
43
47 public function reset(): void
48 {
49 parent::reset();
50 $this->value = null;
51 }
52
53 public function setTargetRefId(?int $a_value): void
54 {
55 $this->value = $a_value;
56 }
57
61 public function getTargetRefId(): ?int
62 {
63 return $this->value;
64 }
65
70 public function equals(ilADT $a_adt): ?bool
71 {
72 if ($this->getDefinition()->isComparableTo($a_adt)) {
73 return strcmp($this->getCheckSum() ?? '', $a_adt->getCheckSum() ?? '') === 0;
74 }
75 return null;
76 }
77
78 public function isLarger(ilADT $a_adt): ?bool
79 {
80 return null;
81 }
82
83 public function isSmaller(ilADT $a_adt): ?bool
84 {
85 return null;
86 }
87
92 public function isNull(): bool
93 {
94 return !$this->getTargetRefId();
95 }
96
97 public function isValid(): bool
98 {
99 $valid = parent::isValid();
100 if (!$this->isNull()) {
101 if (
102 !$this->tree->isInTree($this->getTargetRefId()) ||
103 $this->tree->isDeleted($this->getTargetRefId())
104 ) {
105 $valid = false;
106 $this->addValidationError(self::ADT_VALIDATION_ERROR_INVALID_NODE);
107 }
108 }
109 return $valid;
110 }
111
112 public function getCheckSum(): ?string
113 {
114 if (!$this->isNull()) {
115 return md5((string) $this->getTargetRefId());
116 }
117 return null;
118 }
119
123 public function exportStdClass(): ?stdClass
124 {
125 if (!$this->isNull()) {
126 $obj = new stdClass();
127 $obj->target_ref_id = $this->getTargetRefId();
128
129 return $obj;
130 }
131 return null;
132 }
133
137 public function importStdClass(?stdClass $a_std): void
138 {
139 if (is_object($a_std)) {
140 $this->setTargetRefId($a_std->target_ref_id);
141 }
142 }
143}
ADT definition base class.
ADT base class.
Definition: class.ilADT.php:26
addValidationError(string $a_error_code)
getCheckSum()
Get unique checksum.
getDefinition()
Get definition.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
$valid
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26