xref: /webtrees/app/Http/RequestHandlers/MapDataDeleteUnused.php (revision d11be7027e34e3121be11cc025421873364403f9)
17b5ff3baSGreg Roach<?php
27b5ff3baSGreg Roach
37b5ff3baSGreg Roach/**
47b5ff3baSGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
67b5ff3baSGreg Roach * This program is free software: you can redistribute it and/or modify
77b5ff3baSGreg Roach * it under the terms of the GNU General Public License as published by
87b5ff3baSGreg Roach * the Free Software Foundation, either version 3 of the License, or
97b5ff3baSGreg Roach * (at your option) any later version.
107b5ff3baSGreg Roach * This program is distributed in the hope that it will be useful,
117b5ff3baSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
127b5ff3baSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
137b5ff3baSGreg Roach * GNU General Public License for more details.
147b5ff3baSGreg Roach * You should have received a copy of the GNU General Public License
157b5ff3baSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
167b5ff3baSGreg Roach */
177b5ff3baSGreg Roach
187b5ff3baSGreg Roachdeclare(strict_types=1);
197b5ff3baSGreg Roach
207b5ff3baSGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
217b5ff3baSGreg Roach
227b5ff3baSGreg Roachuse Fisharebest\Webtrees\Services\MapDataService;
237b5ff3baSGreg Roachuse Psr\Http\Message\ResponseInterface;
247b5ff3baSGreg Roachuse Psr\Http\Message\ServerRequestInterface;
257b5ff3baSGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
267b5ff3baSGreg Roach
277b5ff3baSGreg Roachuse function redirect;
287b5ff3baSGreg Roachuse function route;
297b5ff3baSGreg Roach
307b5ff3baSGreg Roach/**
317b5ff3baSGreg Roach * Delete unused locations from the control panel.
327b5ff3baSGreg Roach */
337b5ff3baSGreg Roachclass MapDataDeleteUnused implements RequestHandlerInterface
347b5ff3baSGreg Roach{
357b5ff3baSGreg Roach    private MapDataService $map_data_service;
367b5ff3baSGreg Roach
377b5ff3baSGreg Roach    /**
387b5ff3baSGreg Roach     * Dependency injection.
397b5ff3baSGreg Roach     *
407b5ff3baSGreg Roach     * @param MapDataService $map_data_service
417b5ff3baSGreg Roach     */
427b5ff3baSGreg Roach    public function __construct(MapDataService $map_data_service)
437b5ff3baSGreg Roach    {
447b5ff3baSGreg Roach        $this->map_data_service = $map_data_service;
457b5ff3baSGreg Roach    }
467b5ff3baSGreg Roach
477b5ff3baSGreg Roach    /**
487b5ff3baSGreg Roach     * @param ServerRequestInterface $request
497b5ff3baSGreg Roach     *
507b5ff3baSGreg Roach     * @return ResponseInterface
517b5ff3baSGreg Roach     */
527b5ff3baSGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
537b5ff3baSGreg Roach    {
547b5ff3baSGreg Roach        $this->map_data_service->deleteUnusedLocations(null, [0]);
557b5ff3baSGreg Roach
567b5ff3baSGreg Roach        $url = route(MapDataList::class);
577b5ff3baSGreg Roach
587b5ff3baSGreg Roach        return redirect($url);
597b5ff3baSGreg Roach    }
607b5ff3baSGreg Roach}
61