Skip to content

Commit

Permalink
[TASK] Switch update wizard registration
Browse files Browse the repository at this point in the history
  • Loading branch information
georgringer committed Apr 15, 2024
1 parent 575e63d commit 5c36785
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 61 deletions.
10 changes: 2 additions & 8 deletions Classes/Updates/NewsSlugUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
}
}
7 changes: 2 additions & 5 deletions Classes/Updates/PluginPermissionUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
7 changes: 2 additions & 5 deletions Classes/Updates/PluginUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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';
Expand Down
10 changes: 2 additions & 8 deletions Classes/Updates/PopulateCategorySlugs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
10 changes: 2 additions & 8 deletions Classes/Updates/PopulateTagSlugs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
10 changes: 2 additions & 8 deletions Classes/Updates/RealurlAliasNewsSlugUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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';
Expand Down Expand Up @@ -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
*
Expand Down
7 changes: 2 additions & 5 deletions Classes/Updates/RelatedLinkIntegerDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@
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';
private const FIELD_UID = 'uid';
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(
Expand Down
7 changes: 2 additions & 5 deletions Classes/Updates/TitleFieldDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@
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';
private const FIELD_UID = 'uid';
private const FIELD_RELATED_LINKS = 'title';
private const RELATED_LINKS_DEFAULT_VALUE = '';

public function getIdentifier(): string
{
return 'txNewsTitleFieldDefault';
}

public function getTitle(): string
{
return sprintf(
Expand Down
9 changes: 0 additions & 9 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5c36785

Please sign in to comment.