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:compatibility7 if needed
21 * @internal This class is only meant to be used within EXT:install and is not part of the TYPO3 Core API.
22 */
23class Compatibility7ExtractionUpdate extends AbstractDownloadExtensionUpdate
24{
25    /**
26     * @var string
27     */
28    protected $title = 'Install extension "compatibility7" from TER';
29
30    /**
31     * @var string
32     */
33    protected $extensionKey = 'compatibility7';
34
35    /**
36     * @var array
37     */
38    protected $extensionDetails = [
39        'compatibility7' => [
40            'title' => 'Compatibility Mode for TYPO3 v7',
41            'description' => 'Provides an additional backwards-compatibility layer with legacy functionality for sites that haven\'t fully migrated to TYPO3 v8 yet.',
42            'versionString' => '8.7.1',
43            'composerName' => 'friendsoftypo3/compatibility7',
44        ],
45    ];
46
47    /**
48     * @var \TYPO3\CMS\Install\Updates\ExtensionModel
49     */
50    protected $extension;
51
52    /**
53     * @var \TYPO3\CMS\Install\Updates\Confirmation
54     */
55    protected $confirmation;
56
57    public function __construct()
58    {
59        $this->extension = new ExtensionModel(
60            'compatibility7',
61            'Compatibility Mode for TYPO3 v7',
62            '8.7.1',
63            'friendsoftypo3/compatibility7',
64            'Provides an additional backwards-compatibility layer with legacy functionality for sites that haven\'t fully migrated to TYPO3 v8 yet.'
65        );
66
67        $this->confirmation = new Confirmation(
68            'Are you sure?',
69            'The compatibility extensions come with a performance penalty, use only if needed. ' . $this->extension->getDescription(),
70            false
71        );
72    }
73
74    /**
75     * Return a confirmation message instance
76     *
77     * @return \TYPO3\CMS\Install\Updates\Confirmation
78     */
79    public function getConfirmation(): Confirmation
80    {
81        return $this->confirmation;
82    }
83
84    /**
85     * Return the identifier for this wizard
86     * This should be the same string as used in the ext_localconf class registration
87     *
88     * @return string
89     */
90    public function getIdentifier(): string
91    {
92        return 'compatibility7Extension';
93    }
94
95    /**
96     * Return the speaking name of this wizard
97     *
98     * @return string
99     */
100    public function getTitle(): string
101    {
102        return 'Install compatibility extension for TYPO3 7 compatibility';
103    }
104
105    /**
106     * Return the description for this wizard
107     *
108     * @return string
109     */
110    public function getDescription(): string
111    {
112        return 'The extension "compatibility7" (Compatibility Mode for TYPO3 v7) was extracted into '
113               . 'the TYPO3 Extension Repository. This update downloads the TYPO3 Extension from the TER.';
114    }
115
116    /**
117     * Is an update necessary?
118     * Is used to determine whether a wizard needs to be run.
119     *
120     * @return bool
121     */
122    public function updateNecessary(): bool
123    {
124        return !ExtensionManagementUtility::isLoaded('compatibility7');
125    }
126
127    /**
128     * Returns an array of class names of Prerequisite classes
129     * This way a wizard can define dependencies like "database up-to-date" or
130     * "reference index updated"
131     *
132     * @return string[]
133     */
134    public function getPrerequisites(): array
135    {
136        return [];
137    }
138}
139