ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ComponentEntryDescription.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 
32 {
33  protected array $description = array(
34  "purpose" => "",
35  "composition" => "",
36  "effect" => "",
37  "rivals" => array()
38  );
39 
40  public function __construct(array $description = array())
41  {
43  $this->setDescription($description);
44  }
45 
46  public function withDescription(array $description = array()): ComponentEntryDescription
47  {
48  $clone = clone $this;
49  $clone->setDescription($description);
50  return $clone;
51  }
52 
53  protected function setDescription(array $descriptionElements): void
54  {
55  if (!$descriptionElements) {
56  return;
57  }
58  $this->assert()->isArray($descriptionElements);
59  foreach ($descriptionElements as $category => $element) {
60  $this->assert()->isIndex($category, $this->description);
61 
62  if (is_array($this->description[$category])) {
63  if ($element && $element != "") {
64  $this->assert()->isArray($element);
65  foreach ($element as $key => $part) {
66  $this->assert()->isString($part);
67  $this->description[$category][$key] = $part;
68  }
69  }
70  } else {
71  $this->assert()->isString($element);
72  $this->description[$category] = $element;
73  }
74  }
75  }
76 
81  public function getProperty($key)
82  {
83  $this->assert()->isIndex($key, $this->description);
84 
85  return $this->description[$key];
86  }
87 
88  public function getDescription(): array
89  {
90  return $this->description;
91  }
92 
93  public function jsonSerialize(): array
94  {
95  return $this->getDescription();
96  }
97 }
Abstract Entry Part to share some common entry functionality.
__construct(Container $dic, ilPlugin $plugin)