Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
UpdateController
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 index
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * The Administration Update Controller
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public License,
7 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
8 * obtain one at https://mozilla.org/MPL/2.0/.
9 *
10 * @package   phpMyFAQ
11 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
12 * @copyright 2024-2026 phpMyFAQ Team
13 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
14 * @link      https://www.phpmyfaq.de
15 * @since     2024-11-22
16 */
17
18declare(strict_types=1);
19
20namespace phpMyFAQ\Controller\Administration;
21
22use phpMyFAQ\Core\Exception;
23use phpMyFAQ\Enums\PermissionType;
24use phpMyFAQ\Enums\ReleaseType;
25use phpMyFAQ\Session\Token;
26use Symfony\Component\HttpFoundation\Request;
27use Symfony\Component\HttpFoundation\Response;
28use Symfony\Component\Routing\Attribute\Route;
29use Twig\Error\LoaderError;
30
31final class UpdateController extends AbstractAdministrationController
32{
33    /**
34     * @throws LoaderError
35     * @throws Exception
36     * @throws \Exception
37     */
38    #[Route(path: '/update', name: 'admin.update', methods: ['GET'])]
39    public function index(Request $request): Response
40    {
41        $this->userHasPermission(PermissionType::CONFIGURATION_EDIT);
42
43        $isOnNightlies = $this->configuration->get(item: 'upgrade.releaseEnvironment') === ReleaseType::NIGHTLY->value;
44
45        return $this->render('@admin/configuration/upgrade.twig', [
46            ...$this->getHeader($request),
47            ...$this->getFooter(),
48            'csrfActivateMaintenanceMode' => Token::getInstance($this->session)->getTokenString(
49                'activate-maintenance-mode',
50            ),
51            'csrfUpdatePackage' => Token::getInstance($this->session)->getTokenString('update-package'),
52            'isOnNightlies' => $isOnNightlies,
53            'releaseEnvironment' => ucfirst((string) $this->configuration->get(item: 'upgrade.releaseEnvironment')),
54            'dateLastChecked' => $this->configuration->get(item: 'upgrade.dateLastChecked'),
55            'versionCurrent' => $this->configuration->get(item: 'main.currentVersion'),
56        ]);
57    }
58}