1<?php 2/* 3 * vim:set softtabstop=4 shiftwidth=4 expandtab: 4 * 5 * LICENSE: GNU Affero General Public License, version 3 (AGPL-3.0-or-later) 6 * Copyright 2001 - 2020 Ampache.org 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Affero General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Affero General Public License for more details. 17 * 18 * You should have received a copy of the GNU Affero General Public License 19 * along with this program. If not, see <https://www.gnu.org/licenses/>. 20 * 21 */ 22 23declare(strict_types=1); 24 25namespace Ampache\Module\Application\Artist; 26 27use Ampache\Repository\Model\ModelFactoryInterface; 28use Ampache\Module\Application\ApplicationActionInterface; 29use Ampache\Module\Authorization\GuiGatekeeperInterface; 30use Ampache\Module\Util\UiInterface; 31use Ampache\Repository\SongRepositoryInterface; 32use Psr\Http\Message\ResponseInterface; 33use Psr\Http\Message\ServerRequestInterface; 34 35final class ShowAllSongsAction implements ApplicationActionInterface 36{ 37 public const REQUEST_KEY = 'show_all_songs'; 38 39 private ModelFactoryInterface $modelFactory; 40 41 private UiInterface $ui; 42 43 private SongRepositoryInterface $songRepository; 44 45 public function __construct( 46 ModelFactoryInterface $modelFactory, 47 UiInterface $ui, 48 SongRepositoryInterface $songRepository 49 ) { 50 $this->modelFactory = $modelFactory; 51 $this->ui = $ui; 52 $this->songRepository = $songRepository; 53 } 54 55 public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface 56 { 57 $artistId = (int) ($request->getQueryParams()['artist'] ?? 0); 58 59 $artist = $this->modelFactory->createArtist($artistId); 60 $artist->format(); 61 62 $this->ui->showHeader(); 63 $this->ui->show( 64 'show_artist.inc.php', 65 [ 66 'artist' => $artist, 67 'object_type' => 'song', 68 'object_ids' => $this->songRepository->getByArtist($artistId), 69 'gatekeeper' => $gatekeeper 70 ] 71 ); 72 73 $this->ui->showQueryStats(); 74 $this->ui->showFooter(); 75 76 return null; 77 } 78} 79