1 | <?php |
||
48 | class Term implements ArrayAccess, Arrayable |
||
49 | { |
||
50 | /** |
||
51 | * Data for the term |
||
52 | * |
||
53 | * @var array |
||
54 | */ |
||
55 | private $container = [ |
||
56 | 'has_translations' => true, |
||
57 | 'type' => 0, |
||
58 | ]; |
||
59 | |||
60 | /** |
||
61 | * Create the term |
||
62 | * |
||
63 | 69 | * @param $data |
|
64 | */ |
||
65 | 69 | public function __construct($data) |
|
80 | |||
81 | /** |
||
82 | * Returns true if the vocabulary of the term can be translated |
||
83 | * |
||
84 | 33 | * @return bool |
|
85 | */ |
||
86 | 33 | protected function hasTranslations() |
|
90 | |||
91 | /** |
||
92 | * Returns true if the term is a (sub)category |
||
93 | * |
||
94 | 6 | * @return bool |
|
95 | */ |
||
96 | 6 | public function isSubcategory() |
|
100 | |||
101 | /** |
||
102 | * Returns the type of the term (category or term) |
||
103 | * |
||
104 | 3 | * @return mixed |
|
105 | */ |
||
106 | 3 | public function getType() |
|
110 | |||
111 | /** |
||
112 | * Get the term id |
||
113 | * |
||
114 | 21 | * @return int |
|
115 | */ |
||
116 | 21 | public function id() |
|
120 | |||
121 | /** |
||
122 | * Get the term's title |
||
123 | * |
||
124 | * @param string $language |
||
125 | 27 | * @return string |
|
126 | */ |
||
127 | 27 | public function title($language = '') |
|
131 | |||
132 | /** |
||
133 | * Get the term's description |
||
134 | * |
||
135 | * @param string $language |
||
136 | 15 | * @return string |
|
137 | */ |
||
138 | 15 | public function description($language = '') |
|
142 | |||
143 | /** |
||
144 | * Return the textual version of the term |
||
145 | * |
||
146 | * @param string $key |
||
147 | * @param string $language |
||
148 | 30 | * @return string |
|
149 | */ |
||
150 | 30 | public function string($key, $language = '') |
|
166 | |||
167 | /** |
||
168 | * Is it translated in this language ? |
||
169 | * |
||
170 | * @param string $language |
||
171 | 18 | * @return bool |
|
172 | */ |
||
173 | 18 | public function translated($language = '') |
|
189 | |||
190 | /** |
||
191 | * Add one parent to a term |
||
192 | * |
||
193 | * @param int $parent_id |
||
194 | 15 | * @return mixed |
|
195 | */ |
||
196 | 15 | public function addParent($parent_id) |
|
200 | |||
201 | /** |
||
202 | * Add a list of parents to a term |
||
203 | * |
||
204 | 6 | * @param array<int> $parent_ids |
|
205 | */ |
||
206 | 6 | public function addParents(array $parent_ids) |
|
210 | |||
211 | /** |
||
212 | * Replace the parents on a term by this one |
||
213 | * |
||
214 | 3 | * @param int $parent_id |
|
215 | */ |
||
216 | 3 | public function setParent($parent_id) |
|
222 | |||
223 | /** |
||
224 | * Replace the parents by this list |
||
225 | * |
||
226 | 3 | * @param array<int> $parent_ids |
|
227 | */ |
||
228 | 3 | public function setParents(array $parent_ids) |
|
234 | |||
235 | /** |
||
236 | * Retrieve a language for edition |
||
237 | * |
||
238 | * @param string $language |
||
239 | * @throws UndefinedLanguageException |
||
240 | 6 | * @return Model\TermData |
|
241 | */ |
||
242 | 6 | public function editLanguage($language = '') |
|
250 | |||
251 | /** |
||
252 | * Array access |
||
253 | * |
||
254 | * @param mixed $offset |
||
255 | 3 | * @param mixed $value |
|
256 | */ |
||
257 | 3 | public function offsetSet($offset, $value) |
|
263 | |||
264 | /** |
||
265 | * Array Access |
||
266 | * |
||
267 | * @param mixed $offset |
||
268 | 6 | * @return bool |
|
269 | */ |
||
270 | 6 | public function offsetExists($offset) |
|
274 | |||
275 | /** |
||
276 | * Array Access |
||
277 | * |
||
278 | 3 | * @param mixed $offset |
|
279 | */ |
||
280 | 3 | public function offsetUnset($offset) |
|
284 | |||
285 | /** |
||
286 | * Array access |
||
287 | * |
||
288 | * @param mixed $offset |
||
289 | 21 | * @return mixed|null |
|
290 | */ |
||
291 | 21 | public function offsetGet($offset) |
|
305 | |||
306 | /** |
||
307 | * echo Term - outputs the term in the current language |
||
308 | * |
||
309 | 6 | * @return string |
|
310 | */ |
||
311 | 6 | public function __toString() |
|
315 | |||
316 | public function toArray() |
||
325 | } |
||
326 |