1 | <?php |
||
20 | trait Element |
||
21 | { |
||
22 | use Base; |
||
23 | |||
24 | /** |
||
25 | * @inheritdoc |
||
26 | */ |
||
27 | protected function applyDefaultProperties() |
||
34 | |||
35 | /** |
||
36 | * @var bool |
||
37 | */ |
||
38 | public $overrideText = true; |
||
39 | |||
40 | /** |
||
41 | * @var int |
||
42 | */ |
||
43 | protected $elementId; |
||
44 | |||
45 | /** |
||
46 | * @var ElementInterface |
||
47 | */ |
||
48 | protected $element; |
||
49 | |||
50 | /** |
||
51 | * @return string |
||
52 | */ |
||
53 | abstract protected function getElementText(): string; |
||
54 | |||
55 | /** |
||
56 | * @param int $id |
||
57 | * @return ElementInterface|null |
||
58 | */ |
||
59 | abstract protected function lookupElementById(int $id); |
||
60 | |||
61 | /** |
||
62 | * @return int |
||
63 | */ |
||
64 | public function getElementId() |
||
68 | |||
69 | /** |
||
70 | * @return ElementInterface|null |
||
71 | */ |
||
72 | protected function findElement() |
||
80 | |||
81 | /** |
||
82 | * @return ElementInterface|null |
||
83 | */ |
||
84 | protected function lookupElement() |
||
92 | |||
93 | /** |
||
94 | * @return array |
||
95 | */ |
||
96 | public function properties(): array |
||
103 | |||
104 | /** |
||
105 | * @param $elementId |
||
106 | */ |
||
107 | public function setElementId($elementId) |
||
121 | |||
122 | /** |
||
123 | * @inheritdoc |
||
124 | */ |
||
125 | public function inputHtml(Link $field, TypeInterface $type = null, ElementInterface $element = null): string |
||
137 | |||
138 | /** |
||
139 | * @inheritdoc |
||
140 | */ |
||
141 | public function settingsHtml(): string |
||
151 | |||
152 | /** |
||
153 | * @inheritdoc |
||
154 | */ |
||
155 | public function getText(): string |
||
162 | } |
||
163 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: