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=0); 24 25namespace Ampache\Module\Application\Admin\Catalog; 26 27use Ampache\Config\ConfigContainerInterface; 28use Ampache\Config\ConfigurationKeyEnum; 29use Ampache\Module\Util\UiInterface; 30use Psr\Http\Message\ResponseInterface; 31use Psr\Http\Message\ServerRequestInterface; 32 33final class UpdateCatalogAction extends AbstractCatalogAction 34{ 35 public const REQUEST_KEY = 'update_catalog'; 36 37 private ConfigContainerInterface $configContainer; 38 39 private UiInterface $ui; 40 41 public function __construct( 42 UiInterface $ui, 43 ConfigContainerInterface $configContainer 44 ) { 45 parent::__construct($ui); 46 $this->configContainer = $configContainer; 47 $this->ui = $ui; 48 } 49 50 /** 51 * @param int[] $catalogIds 52 */ 53 protected function handle( 54 ServerRequestInterface $request, 55 array $catalogIds 56 ): ?ResponseInterface { 57 if ($this->configContainer->isFeatureEnabled(ConfigurationKeyEnum::DEMO_MODE) === true) { 58 return null; 59 } 60 61 catalog_worker('update_catalog', $catalogIds); 62 63 $this->ui->showConfirmation( 64 T_('Catalog update process has started'), 65 '', 66 sprintf('%s/admin/catalog.php', $this->configContainer->getWebPath()), 67 0, 68 'confirmation', 69 false 70 ); 71 72 return null; 73 } 74} 75