|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Base daft nested objects. |
|
4
|
|
|
* |
|
5
|
|
|
* @author SignpostMarv |
|
6
|
|
|
*/ |
|
7
|
|
|
declare(strict_types=1); |
|
8
|
|
|
|
|
9
|
|
|
namespace SignpostMarv\DaftObject; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @template T as DaftNestedWriteableObject |
|
13
|
|
|
*/ |
|
14
|
|
|
trait WriteableObjectTrait |
|
15
|
|
|
{ |
|
16
|
86 |
|
public function SetIntNestedLeft(int $value) : void |
|
17
|
|
|
{ |
|
18
|
86 |
|
$this->NudgePropertyValue('intNestedLeft', $value); |
|
19
|
86 |
|
} |
|
20
|
|
|
|
|
21
|
86 |
|
public function SetIntNestedRight(int $value) : void |
|
22
|
|
|
{ |
|
23
|
86 |
|
$this->NudgePropertyValue('intNestedRight', $value); |
|
24
|
86 |
|
} |
|
25
|
|
|
|
|
26
|
60 |
|
public function SetIntNestedLevel(int $value) : void |
|
27
|
|
|
{ |
|
28
|
60 |
|
$this->NudgePropertyValue('intNestedLevel', $value); |
|
29
|
60 |
|
} |
|
30
|
|
|
|
|
31
|
28 |
|
public function SetIntNestedSortOrder(int $value) : void |
|
32
|
|
|
{ |
|
33
|
28 |
|
$this->NudgePropertyValue('intNestedSortOrder', $value); |
|
34
|
28 |
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param mixed $value |
|
38
|
|
|
*/ |
|
39
|
60 |
|
public function AlterDaftNestedObjectParentId($value) : void |
|
40
|
|
|
{ |
|
41
|
|
|
/** |
|
42
|
|
|
* @var string[] |
|
43
|
|
|
*/ |
|
44
|
60 |
|
$props = static::DaftNestedObjectParentIdProperties(); |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var array<string, scalar|array|object|null> |
|
48
|
|
|
*/ |
|
49
|
60 |
|
$propsAndVals = array_combine($props, (is_array($value) ? $value : [$value])); |
|
50
|
|
|
|
|
51
|
60 |
|
foreach ($propsAndVals as $prop => $val) { |
|
52
|
60 |
|
$this->NudgePropertyValue($prop, $val); |
|
53
|
|
|
} |
|
54
|
60 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return array<int, string> |
|
58
|
|
|
*/ |
|
59
|
|
|
abstract public static function DaftNestedObjectParentIdProperties() : array; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @see AbstractDaftObject::NudgePropertyValue() |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $property property being nudged |
|
65
|
|
|
* @param scalar|array|object|null $value value to nudge property with |
|
66
|
|
|
*/ |
|
67
|
|
|
abstract protected function NudgePropertyValue( |
|
68
|
|
|
string $property, |
|
69
|
|
|
$value, |
|
70
|
|
|
bool $autoTrimStrings = AbstractArrayBackedDaftObject::BOOL_DEFAULT_AUTOTRIMSTRINGS, |
|
71
|
|
|
bool $throwIfNotUnique = AbstractArrayBackedDaftObject::BOOL_DEFAULT_THROWIFNOTUNIQUE |
|
72
|
|
|
) : void; |
|
73
|
|
|
} |
|
74
|
|
|
|