Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 44
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
OlzServiceParams
n/a
0 / 0
n/a
0 / 0
0
n/a
0 / 0
OlzService
0.00% covered (danger)
0.00%
0 / 44
0.00% covered (danger)
0.00%
0 / 3
72
0.00% covered (danger)
0.00%
0 / 1
 getSearchTitle
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getSearchResults
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 1
42
 getHtml
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Olz\Service\Components\OlzService;
4
5use Olz\Components\Apps\OlzAppsList\OlzAppsList;
6use Olz\Components\Common\OlzRootComponent;
7use Olz\Components\Page\OlzFooter\OlzFooter;
8use Olz\Components\Page\OlzHeader\OlzHeader;
9use Olz\Entity\Service\Download;
10use Olz\Entity\Service\Link;
11use Olz\Service\Components\OlzDownloads\OlzDownloads;
12use Olz\Service\Components\OlzLinks\OlzLinks;
13use Olz\Utils\HttpParams;
14
15/** @extends HttpParams<array{}> */
16class OlzServiceParams extends HttpParams {
17}
18
19/** @extends OlzRootComponent<array<string, mixed>> */
20class OlzService extends OlzRootComponent {
21    public function getSearchTitle(): string {
22        return 'Service';
23    }
24
25    public function getSearchResults(array $terms): array {
26        $results = [];
27        $code_href = $this->envUtils()->getCodeHref();
28        $download_repo = $this->entityManager()->getRepository(Download::class);
29        $downloads = $download_repo->search($terms);
30        foreach ($downloads as $download) {
31            $results[] = $this->searchUtils()->getScoredSearchResult([
32                'link' => "{$code_href}service",
33                'icon' => "{$code_href}assets/icns/link_internal_16.svg", // TODO better icon
34                'date' => null,
35                'title' => $download->getName() ?: '?',
36                'text' => null,
37            ], $terms);
38        }
39        $link_repo = $this->entityManager()->getRepository(Link::class);
40        $links = $link_repo->search($terms);
41        foreach ($links as $link) {
42            $results[] = $this->searchUtils()->getScoredSearchResult([
43                'link' => "{$code_href}service",
44                'icon' => "{$code_href}assets/icns/link_internal_16.svg", // TODO better icon
45                'date' => null,
46                'title' => $link->getName() ?: '?',
47                'text' => $link->getUrl() ?: null,
48            ], $terms);
49        }
50        return $results;
51    }
52
53    public static string $title = "Service";
54    public static string $description = "Diverse Online-Tools rund um OL und die OL Zimmerberg.";
55
56    public function getHtml(mixed $args): string {
57        $this->httpUtils()->validateGetParams(OlzServiceParams::class);
58
59        $out = OlzHeader::render([
60            'title' => self::$title,
61            'description' => self::$description,
62        ]);
63
64        $out .= "<div class='content-full'>";
65
66        $out .= "<h1>Service</h1>";
67        $out .= "<h2>Apps</h2>";
68        $out .= OlzAppsList::render();
69        $out .= "<br /><br />";
70
71        $out .= "<div class='responsive-flex'>";
72        $out .= "<div class='responsive-flex-2'>";
73        $out .= OlzLinks::render();
74        $out .= "</div>";
75        $out .= "<div class='responsive-flex-2'>";
76        $out .= OlzDownloads::render();
77        $out .= "</div></div><br><br>";
78
79        $out .= "</div>";
80
81        $out .= OlzFooter::render();
82
83        return $out;
84    }
85}