ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ComponentEntry.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2016 Timon Amstutz <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
4
6
13{
17 protected $id = "";
18
22 protected $title = "";
23
27 protected $is_abstract = false;
28
32 protected $status_list_entry = array("Accepted","Proposed","To be revised");
33
37 protected $status_list_implementation = array("Implemented","Partly implemented","To be implemented");
38
42 protected $status_entry = "";
43
47 protected $status_implementation = "";
48
52 protected $description = null;
53
57 protected $background = "";
58
62 protected $selector = "";
63
67 protected $feature_wiki_references = array();
68
72 protected $rules = null;
73
77 protected $parent = false;
78
82 protected $children = array();
83
87 protected $less_variables = array();
88
92 protected $path = "";
93
94
98 protected $examples = null;
99
103 protected $examples_path = "";
104
110 public function __construct($entry_data) {
111 parent::__construct();
112 $this->assert()->isIndex('id',$entry_data);
113 $this->setId($entry_data['id']);
114 $this->assert()->isIndex('title',$entry_data);
115 $this->setTitle($entry_data['title']);
116 $this->assert()->isIndex('abstract',$entry_data);
117 $this->setIsAbstract($entry_data['abstract']);
118 $this->setStatusEntry("Proposed");
119 $this->setStatusImplementation("Partly implemented");
120 if(array_key_exists('description',$entry_data)) {
121 $this->setDescription(new ComponentEntryDescription($entry_data['description']));
122 }
123 if(array_key_exists('rules',$entry_data)) {
124 $this->setRules(new ComponentEntryRules($entry_data['rules']));
125 }
126
127 $this->assert()->isIndex('path',$entry_data);
128 $this->setPath($entry_data['path']);
129
130 if(array_key_exists('background',$entry_data)){
131 $this->setBackground($entry_data['background']);
132 }
133 if(array_key_exists('featurewiki',$entry_data)){
134 $this->setFeatureWikiReferences($entry_data['featurewiki']);
135 }
136 if(array_key_exists('parent',$entry_data)){
137 $this->setParent($entry_data['parent']);
138 }
139 if(array_key_exists('children',$entry_data)){
140 $this->setChildren($entry_data['children']);
141 }
142
143 if(!$this->isAbstract()){
144 $this->readExamples();
145 }
146 }
147
151 public function getId()
152 {
153 return $this->id;
154 }
155
159 public function setId($id)
160 {
161 $this->assert()->isString($id,false);
162 $this->id = $id;
163 }
164
168 public function getTitle()
169 {
170 return $this->title;
171 }
172
176 public function setTitle($title){
177 $this->assert()->isString($title,false);
178 $this->title = $title;
179 }
180
184 public function isAbstract()
185 {
186 return $this->is_abstract;
187 }
188
193 {
194 $this->is_abstract = $is_abstract;
195 }
196
200 public function getStatusEntry()
201 {
202 return $this->status_entry;
203 }
204
209 {
210 $this->assert()->isString($status_entry);
211 //$this->assert()->isIndex($status_entry,$this->status_list_entry);
212
213 $this->status_entry = $status_entry;
214 }
215
219 public function getStatusImplementation()
220 {
222 }
223
228 {
229 $this->assert()->isString($status_implementation);
230 //$this->assert()->isIndex($status_implementation,$this->status_list_implementation);
231
232 $this->status_implementation = $status_implementation;
233
234 }
235
239 public function getDescription()
240 {
241 return $this->description;
242 }
243
247 public function getDescriptionAsArray()
248 {
249 return $this->description->getDescription();
250 }
251
257 {
258 $this->assert()->isTypeOf($description,ComponentEntryDescription::class);
259 $this->description = $description;
260 }
261
265 public function getBackground()
266 {
267 return $this->background;
268 }
269
273 public function setBackground($background)
274 {
275 $this->assert()->isString($background);
276 $this->background = $background;
277 }
278
282 public function getFeatureWikiReferences()
283 {
285 }
286
291 {
292 $this->assert()->isArray($feature_wiki_references);
293 $this->feature_wiki_references = $feature_wiki_references;
294 }
295
299 public function getRules()
300 {
301 return $this->rules;
302 }
303
307 public function getRulesAsArray()
308 {
309 if($this->rules){
310 return $this->rules->getRules();
311 }
312 else{
313 return [];
314 }
315 }
316
320 public function setRules($rules)
321 {
322 $this->assert()->isTypeOf($rules,ComponentEntryRules::class);
323 $this->rules = $rules;
324 }
325
329 public function getSelector()
330 {
331 return $this->selector;
332 }
333
337 public function setSelector($selector)
338 {
339 $this->assert()->isString($selector);
340 $this->selector = $selector;
341 }
342
347 {
348 $this->assert()->isArray($less_variables);
349 $this->less_variables = $less_variables;
350 }
351
355 public function getLessVariables()
356 {
358 }
359
363 public function getPath()
364 {
365 return $this->path;
366 }
367
371 public function setPath($path)
372 {
373 $this->assert()->isString($path);
374 $this->path = $path;
375 }
376
380 public function getParent()
381 {
382 return $this->parent;
383 }
384
388 public function setParent($parent)
389 {
390 $this->parent = $parent;
391 }
392
396 public function getChildren()
397 {
398 return $this->children;
399 }
400
404 public function setChildren($children)
405 {
406 $this->children = $children;
407 }
408
412 public function addChild($child)
413 {
414 $this->children[] = $child;
415 }
416
420 public function addChildren($children)
421 {
422 $this->setChildren(array_merge($this->children,$children));
423 }
424
428 public function getExamples()
429 {
430 return $this->examples;
431 }
432
436 protected function readExamples()
437 {
438 $this->examples = array();
439 if(is_dir($this->getExamplesPath())){
440 foreach (scandir($this->getExamplesPath()) as $file_name) {
441 $example_path = $this->getExamplesPath()."/".$file_name;
442 if(is_file($example_path) && pathinfo($example_path)["extension"] =="php"){
443 $example_name = str_replace(".php","",$file_name);
444 $this->examples[$example_name] = $example_path;
445 }
446 }
447 }
448 }
449
450 public function getExamplesPath(){
451 if(!$this->examples_path){
452 $path_componants = str_replace("Component","examples",$this->getPath())
453 ."/".str_replace(" ", "", $this->getTitle());
454 $path_array = array_unique(explode ("/",$path_componants));
455 $this->examples_path = implode("/",$path_array);
456 }
458 }
459
460
464 public function jsonSerialize() {
465 return array(
466 'id' => $this->getId(),
467 'title' => $this->getTitle(),
468 'abstract' => $this->isAbstract(),
469 'status_entry' => $this->getStatusEntry(),
470 'status_implementation' => $this->getStatusImplementation(),
471 'description' => $this->getDescription(),
472 'background ' => $this->getBackground(),
473 'selector' => $this->getSelector(),
474 'feature_wiki_references ' => $this->getFeatureWikiReferences(),
475 'rules' => $this->getRules(),
476 'parent' => $this->getParent(),
477 'children' => $this->getChildren(),
478 'less_variables' => $this->getLessVariables(),
479 'path' => $this->getPath()
480 );
481 }
482}
An exception for terminatinating execution or to throw for unit testing.
Abstract Entry Part to share some common entry functionality.
Stores Information of UI Components parsed from YAML, examples and less files.
setDescription(ComponentEntryDescription $description)
__construct($entry_data)
ComponentEntry constructor.