1<?php
2namespace TYPO3\CMS\Install\Updates;
3
4/*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
18
19/**
20 * Installs and downloads EXT:func
21 * @internal This class is only meant to be used within EXT:install and is not part of the TYPO3 Core API.
22 */
23class FuncExtractionUpdate extends AbstractDownloadExtensionUpdate
24{
25
26    /**
27     * @var \TYPO3\CMS\Install\Updates\Confirmation
28     */
29    protected $confirmation;
30
31    public function __construct()
32    {
33        $this->extension = new ExtensionModel(
34            'func',
35            'Web->Functions module',
36            '9.0.1',
37            'friendsoftypo3/cms-func',
38            'Provides Web->Functions BE module used in previous TYPO3 versions for extensions that still rely on it.'
39        );
40
41        $this->confirmation = new Confirmation(
42            'Are you sure?',
43            'You should install EXT:func only if you really need it. ' . $this->extension->getDescription(),
44            false
45        );
46    }
47
48    /**
49     * Return a confirmation message instance
50     *
51     * @return \TYPO3\CMS\Install\Updates\Confirmation
52     */
53    public function getConfirmation(): Confirmation
54    {
55        return $this->confirmation;
56    }
57
58    /**
59     * Return the identifier for this wizard
60     * This should be the same string as used in the ext_localconf class registration
61     *
62     * @return string
63     */
64    public function getIdentifier(): string
65    {
66        return 'funcExtension';
67    }
68
69    /**
70     * Return the speaking name of this wizard
71     *
72     * @return string
73     */
74    public function getTitle(): string
75    {
76        return 'Install extension "func" from TER';
77    }
78
79    /**
80     * Return the description for this wizard
81     *
82     * @return string
83     */
84    public function getDescription(): string
85    {
86        return 'The extension "func" that brings the "Web->Functions" backend module has been extracted to'
87               . ' the TYPO3 Extension Repository. This update downloads the TYPO3 extension func from the TER.'
88               . ' Use this if you\'re dealing with extensions in the instance that rely on "Web->Functions" and bring own'
89               . ' modules.';
90    }
91
92    /**
93     * Is an update necessary?
94     * Is used to determine whether a wizard needs to be run.
95     *
96     * @return bool
97     */
98    public function updateNecessary(): bool
99    {
100        return !ExtensionManagementUtility::isLoaded($this->extension->getKey());
101    }
102
103    /**
104     * Returns an array of class names of Prerequisite classes
105     * This way a wizard can define dependencies like "database up-to-date" or
106     * "reference index updated"
107     *
108     * @return string[]
109     */
110    public function getPrerequisites(): array
111    {
112        return [];
113    }
114}
115