1 | <?php |
||
26 | trait TargetAttributeTrait |
||
27 | { |
||
28 | use ActiveRecordTrait; |
||
29 | |||
30 | /** |
||
31 | * @var Element|ElementInterface|null |
||
32 | */ |
||
33 | private $target; |
||
34 | |||
35 | /** |
||
36 | * @param string $attribute |
||
37 | * @return Element|ElementInterface|null |
||
38 | */ |
||
39 | abstract protected function resolveElementFromIdAttribute(string $attribute); |
||
40 | |||
41 | /** |
||
42 | * @param mixed $element |
||
43 | * @return Element|ElementInterface|null |
||
44 | */ |
||
45 | abstract protected function resolveElement($element = null); |
||
46 | |||
47 | /** |
||
48 | * @return bool |
||
49 | */ |
||
50 | public function isTargetSet(): bool |
||
54 | |||
55 | /** |
||
56 | * @return array |
||
57 | */ |
||
58 | protected function targetRules(): array |
||
80 | |||
81 | /** |
||
82 | * @inheritdoc |
||
83 | */ |
||
84 | public function targetAttributeLabels(): array |
||
90 | |||
91 | /** |
||
92 | * @param int|null $id |
||
93 | * @return $this |
||
94 | */ |
||
95 | public function setTargetId(int $id = null) |
||
104 | |||
105 | /** |
||
106 | * Get associated targetId |
||
107 | * |
||
108 | * @return int|null |
||
109 | */ |
||
110 | public function getTargetId() |
||
118 | |||
119 | /** |
||
120 | * @param mixed $target |
||
121 | * @return $this |
||
122 | */ |
||
123 | public function setTarget($target = null) |
||
135 | |||
136 | /** |
||
137 | * @return Element|ElementInterface|null |
||
138 | */ |
||
139 | public function getTarget() |
||
155 | } |
||
156 |