. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\MediaFileService; use Fisharebest\Webtrees\Validator; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function redirect; use function route; /** * Manage media from the control panel. */ class ManageMediaAction implements RequestHandlerInterface { private MediaFileService $media_file_service; /** * @param MediaFileService $media_file_service */ public function __construct(MediaFileService $media_file_service) { $this->media_file_service = $media_file_service; } /** * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $data_filesystem = Registry::filesystem()->data(); $media_folders = $this->media_file_service->allMediaFolders($data_filesystem)->all(); return redirect(route(ManageMediaPage::class, [ 'files' => Validator::parsedBody($request)->string('files'), 'media_folder' => Validator::parsedBody($request)->isInArray($media_folders)->string('media_folder'), 'subfolders' => Validator::parsedBody($request)->string('subfolders'), ])); } }