ILIAS  release_8 Revision v8.24
class.ilSystemStyleLessVariable.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21/***
22 * Capsules data of a less variable in the variables to less file. A less variable has the following structure:
23 * //** Comment to describe the variable
24 * @variable: value;
25 */
27{
31 protected string $name = '';
32
36 protected string $value = '';
37
41 protected string $comment = '';
42
46 protected string $category_name = '';
47
51 protected array $references = [];
52
53 public function __construct(
54 string $name,
55 string $value,
56 string $comment,
57 string $category_name,
58 array $references = []
59 ) {
60 $this->setName($name);
61 $this->setValue($value);
62 $this->setCategoryName($category_name);
63 $this->setComment($comment);
64 $this->setReferences($references);
65 }
66
67 public function getName(): string
68 {
69 return $this->name;
70 }
71
72 public function setName(string $name): void
73 {
74 $this->name = $name;
75 }
76
77 public function getValue(): string
78 {
79 return $this->value;
80 }
81
82 public function setValue(string $value): void
83 {
84 if ($this->getName() == 'il-icon-font-path') {
85 if ($value[0] != "\"") {
86 $value = "\"" . $value;
87 }
88 if (substr($value, -1, 1) != "\"") {
89 $value .= "\"";
90 }
91
92 if ($value == "\"../../node_modules/bootstrap/fonts/\"") {
93 $value = "\"../../../../node_modules/bootstrap/fonts/\"";
94 }
95 }
96
97 $value = str_replace(PHP_EOL, '', $value);
98 $this->value = str_replace("\n", '', $value);
99 }
100
101 public function getComment(): string
102 {
103 return $this->comment;
104 }
105
106 public function setComment(string $comment): void
107 {
108 $comment = str_replace(PHP_EOL, '', $comment);
109 $this->comment = str_replace("\n", '', $comment);
110 }
111
112 public function getCategoryName(): string
113 {
115 }
116
117 public function setCategoryName(string $category_name): void
118 {
119 $this->category_name = $category_name;
120 }
121
122 public function getReferences(): array
123 {
124 return $this->references;
125 }
126
127 public function setReferences(array $references): void
128 {
129 $this->references = $references;
130 }
131
136 public function __toString(): string
137 {
138 $content = '';
139 if ($this->getComment()) {
140 $content .= '//** ' . $this->getComment() . "\n";
141 }
142 $content .= '@' . $this->getName() . ":\t\t" . $this->getValue() . ";\n";
143 return $content;
144 }
145}
Abstracts content of a less file.
array $references
Set references to other variables that are used by this exact variable.
string $comment
Comment to the variable as in the less file.
string $value
Value of the variable as set in the less file.
__toString()
This function will be needed to write the variable back to the less file and restore it's initial str...
__construct(string $name, string $value, string $comment, string $category_name, array $references=[])
string $category_name
Less Category which encloses this variable.