Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
OlzCustomTile | |
0.00% |
0 / 10 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
getRelevance | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
getHtml | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getContent | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | // ============================================================================= |
4 | // Zeigt eine Startseiten-Kachel mit manuell eingegebenem Inhalt an. |
5 | // ============================================================================= |
6 | |
7 | namespace Olz\Startseite\Components\OlzCustomTile; |
8 | |
9 | use Olz\Components\Common\OlzEditableText\OlzEditableText; |
10 | use Olz\Entity\Users\User; |
11 | use Olz\Startseite\Components\AbstractOlzTile\AbstractOlzTile; |
12 | |
13 | class OlzCustomTile extends AbstractOlzTile { |
14 | public const SNIPPET_ID = 24; |
15 | |
16 | public function getRelevance(?User $user): float { |
17 | $is_empty = $this->getContent() === null; |
18 | return ($is_empty) ? 0.0 : 0.9; |
19 | } |
20 | |
21 | public function getHtml(mixed $args): string { |
22 | $content = $this->getContent(); |
23 | return "<h3>Wichtig</h3><div>{$content}</div>"; |
24 | } |
25 | |
26 | protected function getContent(): ?string { |
27 | $snippet_id = self::SNIPPET_ID; |
28 | $has_access = $this->authUtils()->hasPermission("snippet_{$snippet_id}"); |
29 | $content = OlzEditableText::render(['snippet_id' => $snippet_id]); |
30 | if (trim(strip_tags($content)) === '' && !$has_access) { |
31 | return null; |
32 | } |
33 | return $content; |
34 | } |
35 | } |