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