From 5c36785b0179db1c379404f8a77f31d6184fe6d0 Mon Sep 17 00:00:00 2001 From: Georg Ringer Date: Mon, 15 Apr 2024 21:48:56 +0200 Subject: [PATCH] [TASK] Switch update wizard registration --- Classes/Updates/NewsSlugUpdater.php | 10 ++-------- Classes/Updates/PluginPermissionUpdater.php | 7 ++----- Classes/Updates/PluginUpdater.php | 7 ++----- Classes/Updates/PopulateCategorySlugs.php | 10 ++-------- Classes/Updates/PopulateTagSlugs.php | 10 ++-------- Classes/Updates/RealurlAliasNewsSlugUpdater.php | 10 ++-------- Classes/Updates/RelatedLinkIntegerDefault.php | 7 ++----- Classes/Updates/TitleFieldDefault.php | 7 ++----- ext_localconf.php | 9 --------- 9 files changed, 16 insertions(+), 61 deletions(-) diff --git a/Classes/Updates/NewsSlugUpdater.php b/Classes/Updates/NewsSlugUpdater.php index 40ebc9496f..e3a903a751 100644 --- a/Classes/Updates/NewsSlugUpdater.php +++ b/Classes/Updates/NewsSlugUpdater.php @@ -12,12 +12,14 @@ namespace GeorgRinger\News\Updates; use GeorgRinger\News\Service\SlugService; +use TYPO3\CMS\Install\Attribute\UpgradeWizard; use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; /** * Migrate empty slugs */ +#[UpgradeWizard('newsSlug')] class NewsSlugUpdater implements UpgradeWizardInterface { public const TABLE = 'tx_news_domain_model_news'; @@ -74,12 +76,4 @@ public function getDescription(): string { return 'Fills empty slug field "path_segment" of EXT:news records with urlized title.'; } - - /** - * @return string Unique identifier of this updater - */ - public function getIdentifier(): string - { - return 'newsSlug'; - } } diff --git a/Classes/Updates/PluginPermissionUpdater.php b/Classes/Updates/PluginPermissionUpdater.php index 84855f2dbd..6f4307cf46 100644 --- a/Classes/Updates/PluginPermissionUpdater.php +++ b/Classes/Updates/PluginPermissionUpdater.php @@ -15,16 +15,13 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Install\Attribute\UpgradeWizard; use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; +#[UpgradeWizard('txNewsPluginPermissionUpdater')] class PluginPermissionUpdater implements UpgradeWizardInterface { - public function getIdentifier(): string - { - return 'txNewsPluginPermissionUpdater'; - } - public function getTitle(): string { return 'EXT:news: Migrate plugin permissions'; diff --git a/Classes/Updates/PluginUpdater.php b/Classes/Updates/PluginUpdater.php index d5b4eb1fb7..811efd8b41 100644 --- a/Classes/Updates/PluginUpdater.php +++ b/Classes/Updates/PluginUpdater.php @@ -20,9 +20,11 @@ use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Service\FlexFormService; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Install\Attribute\UpgradeWizard; use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; +#[UpgradeWizard('txNewsPluginUpdater')] class PluginUpdater implements UpgradeWizardInterface { private const MIGRATION_SETTINGS = [ @@ -85,11 +87,6 @@ public function __construct() $this->eventDispatcher = GeneralUtility::makeInstance(EventDispatcherInterface::class); } - public function getIdentifier(): string - { - return 'txNewsPluginUpdater'; - } - public function getTitle(): string { return 'EXT:news: Migrate plugins'; diff --git a/Classes/Updates/PopulateCategorySlugs.php b/Classes/Updates/PopulateCategorySlugs.php index 9b5ad6539f..0f16102a66 100644 --- a/Classes/Updates/PopulateCategorySlugs.php +++ b/Classes/Updates/PopulateCategorySlugs.php @@ -17,26 +17,20 @@ use TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory; use TYPO3\CMS\Core\DataHandling\SlugHelper; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Install\Attribute\UpgradeWizard; use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; /** * Fills sys_category.slug with a proper value */ +#[UpgradeWizard('sysCategorySlugs')] class PopulateCategorySlugs implements UpgradeWizardInterface { protected $table = 'sys_category'; protected $fieldName = 'slug'; - /** - * @return string Unique identifier of this updater - */ - public function getIdentifier(): string - { - return 'sysCategorySlugs'; - } - /** * @return string Title of this updater */ diff --git a/Classes/Updates/PopulateTagSlugs.php b/Classes/Updates/PopulateTagSlugs.php index 1615991783..231fe8c38d 100644 --- a/Classes/Updates/PopulateTagSlugs.php +++ b/Classes/Updates/PopulateTagSlugs.php @@ -17,26 +17,20 @@ use TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory; use TYPO3\CMS\Core\DataHandling\SlugHelper; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Install\Attribute\UpgradeWizard; use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; /** * Fills tx_news_domain_model_tag.slug with a proper value */ +#[UpgradeWizard('txNewsTagSlugs')] class PopulateTagSlugs implements UpgradeWizardInterface { protected $table = 'tx_news_domain_model_tag'; protected $fieldName = 'slug'; - /** - * @return string Unique identifier of this updater - */ - public function getIdentifier(): string - { - return 'txNewsTagSlugs'; - } - /** * @return string Title of this updater */ diff --git a/Classes/Updates/RealurlAliasNewsSlugUpdater.php b/Classes/Updates/RealurlAliasNewsSlugUpdater.php index c10fcd7fcb..e36773a641 100644 --- a/Classes/Updates/RealurlAliasNewsSlugUpdater.php +++ b/Classes/Updates/RealurlAliasNewsSlugUpdater.php @@ -25,6 +25,7 @@ */ use GeorgRinger\News\Service\SlugService; +use TYPO3\CMS\Install\Attribute\UpgradeWizard; use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite; use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; @@ -38,6 +39,7 @@ * Will only appear if missing slugs found between realurl and news, respecting language and expire date from realurl * Copies values from 'tx_realurl_uniqalias.value_alias' to 'tx_news_domain_model_news.path_segment' */ +#[UpgradeWizard('realurlAliasNewsSlug')] class RealurlAliasNewsSlugUpdater implements UpgradeWizardInterface { public const TABLE = 'tx_news_domain_model_news'; @@ -103,14 +105,6 @@ public function getDescription(): string return 'Migrates EXT:realurl unique alias values into empty slug field "path_segment" of EXT:news records.'; } - /** - * @return string Unique identifier of this updater - */ - public function getIdentifier(): string - { - return 'realurlAliasNewsSlug'; - } - /** * Second step: Ask user to install the extensions * diff --git a/Classes/Updates/RelatedLinkIntegerDefault.php b/Classes/Updates/RelatedLinkIntegerDefault.php index a6c24e8870..76a48c5f7c 100644 --- a/Classes/Updates/RelatedLinkIntegerDefault.php +++ b/Classes/Updates/RelatedLinkIntegerDefault.php @@ -15,11 +15,13 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Install\Attribute\UpgradeWizard; use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; /** * Migrate default value of related links */ +#[UpgradeWizard('txNewsRelatedLinkIntegerDefault')] final class RelatedLinkIntegerDefault implements UpgradeWizardInterface { private const TABLE_NEWS = 'tx_news_domain_model_news'; @@ -27,11 +29,6 @@ final class RelatedLinkIntegerDefault implements UpgradeWizardInterface private const FIELD_RELATED_LINKS = 'related_links'; private const RELATED_LINKS_DEFAULT_VALUE = '0'; - public function getIdentifier(): string - { - return 'txNewsRelatedLinkIntegerDefault'; - } - public function getTitle(): string { return sprintf( diff --git a/Classes/Updates/TitleFieldDefault.php b/Classes/Updates/TitleFieldDefault.php index 9f7c0c602d..2be3a31586 100644 --- a/Classes/Updates/TitleFieldDefault.php +++ b/Classes/Updates/TitleFieldDefault.php @@ -15,11 +15,13 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Install\Attribute\UpgradeWizard; use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; /** * Migrate default value of title field */ +#[UpgradeWizard('txNewsTitleFieldDefault')] final class TitleFieldDefault implements UpgradeWizardInterface { private const TABLE_NEWS = 'tx_news_domain_model_news'; @@ -27,11 +29,6 @@ final class TitleFieldDefault implements UpgradeWizardInterface private const FIELD_RELATED_LINKS = 'title'; private const RELATED_LINKS_DEFAULT_VALUE = ''; - public function getIdentifier(): string - { - return 'txNewsTitleFieldDefault'; - } - public function getTitle(): string { return sprintf( diff --git a/ext_localconf.php b/ext_localconf.php index fcca138b1d..9c8a232176 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -171,15 +171,6 @@ ], ]; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['realurlAliasNewsSlug'] = \GeorgRinger\News\Updates\RealurlAliasNewsSlugUpdater::class; // Recommended before 'newsSlug' - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['newsSlug'] = \GeorgRinger\News\Updates\NewsSlugUpdater::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['sysCategorySlugs'] = \GeorgRinger\News\Updates\PopulateCategorySlugs::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['txNewsTagSlugs'] = \GeorgRinger\News\Updates\PopulateTagSlugs::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['txNewsRelatedLinkIntegerDefault'] = \GeorgRinger\News\Updates\RelatedLinkIntegerDefault::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['txNewsTitleFieldDefault'] = \GeorgRinger\News\Updates\TitleFieldDefault::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['txNewsPluginUpdater'] = \GeorgRinger\News\Updates\PluginUpdater::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['txNewsPluginPermissionUpdater'] = \GeorgRinger\News\Updates\PluginPermissionUpdater::class; - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup(trim(' plugin { tx_news_newsliststicky.view.pluginNamespace = tx_news_pi1