Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 36
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
OlzTerminLocationsListParams
n/a
0 / 0
n/a
0 / 0
0
n/a
0 / 0
OlzTerminLocationsList
0.00% covered (danger)
0.00%
0 / 36
0.00% covered (danger)
0.00%
0 / 4
30
0.00% covered (danger)
0.00%
0 / 1
 hasAccess
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getSearchTitle
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getSearchResultsWhenHasAccess
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHtmlWhenHasAccess
0.00% covered (danger)
0.00%
0 / 33
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace Olz\Termine\Components\OlzTerminLocationsList;
4
5use Olz\Components\Common\OlzRootComponent;
6use Olz\Components\Page\OlzFooter\OlzFooter;
7use Olz\Components\Page\OlzHeader\OlzHeader;
8use Olz\Entity\Termine\TerminLocation;
9use Olz\Utils\HttpParams;
10
11/** @extends HttpParams<array{}> */
12class OlzTerminLocationsListParams extends HttpParams {
13}
14
15/** @extends OlzRootComponent<array<string, mixed>> */
16class OlzTerminLocationsList extends OlzRootComponent {
17    public function hasAccess(): bool {
18        return $this->authUtils()->hasPermission('termine');
19    }
20
21    public function getSearchTitle(): string {
22        return 'TODO';
23    }
24
25    public function getSearchResultsWhenHasAccess(array $terms): array {
26        return [];
27    }
28
29    public function getHtmlWhenHasAccess(mixed $args): string {
30        $this->httpUtils()->validateGetParams(OlzTerminLocationsListParams::class);
31        $code_href = $this->envUtils()->getCodeHref();
32
33        $out = OlzHeader::render([
34            'back_link' => "{$code_href}termine",
35            'title' => 'Termin-Orte',
36            'description' => "Orte, an denen Anlässe der OL Zimmerberg stattfinden.",
37            'norobots' => true,
38        ]);
39
40        // Creation Tools
41        $has_termine_permissions = $this->authUtils()->hasPermission('termine');
42        $creation_tools = '';
43        if ($has_termine_permissions) {
44            $creation_tools .= <<<ZZZZZZZZZZ
45                <div class='create-termin-location-container'>
46                    <button
47                        id='create-termin-location-button'
48                        class='btn btn-secondary'
49                        onclick='return olz.initOlzEditTerminLocationModal()'
50                    >
51                        <img src='{$code_href}assets/icns/new_white_16.svg' class='noborder' />
52                        Neuen Ort hinzufügen
53                    </button>
54                </div>
55                ZZZZZZZZZZ;
56        }
57
58        $termin_location_repo = $this->entityManager()->getRepository(TerminLocation::class);
59        $termin_locations = $termin_location_repo->findBy(['on_off' => 1]);
60        $locations_data = array_map(function (TerminLocation $termin_location) use ($code_href) {
61            return [
62                'url' => "{$code_href}termine/orte/{$termin_location->getId()}",
63                'name' => $termin_location->getName(),
64                'lat' => $termin_location->getLatitude(),
65                'lng' => $termin_location->getLongitude(),
66            ];
67        }, $termin_locations);
68        $locations_json = json_encode($locations_data);
69
70        $out .= <<<ZZZZZZZZZZ
71            <div class='content-full'>
72                {$creation_tools}
73                <h1>Termin-Orte</h1>
74                <div id='olz-termin-locations-map' class='test-flaky'></div>
75                <script>olz.olzTerminLocationsMapRender({$locations_json});</script>
76            </div>
77            ZZZZZZZZZZ;
78
79        $out .= OlzFooter::render();
80
81        return $out;
82    }
83}