-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Create upgrade wizard for blogexample_pi1 (#99)
* [BUGFIX] Prevent type errors if subtitle is not set releases: main * [TASK] Create upgrade wizard for blogexample_pi1 Had to remove rector from the composer.json as typo3/cms-install depends on nikic/php-parser 5 while rector still depends on 4 releases: main
- Loading branch information
Showing
2 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace T3docs\BlogExample\Upgrades; | ||
|
||
use TYPO3\CMS\Core\Database\ConnectionPool; | ||
use TYPO3\CMS\Install\Attribute\UpgradeWizard; | ||
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; | ||
|
||
#[UpgradeWizard('blogExample_pluginUpgradeWizard')] | ||
final class PluginUpgradeWizard implements UpgradeWizardInterface | ||
{ | ||
private const OLD_LIST_TYPE = 'blogexample_pi1'; | ||
private const NEW_LIST_TYPE = 'blogexample_bloglist'; | ||
public function __construct( | ||
private readonly ConnectionPool $connectionPool, | ||
) {} | ||
|
||
public function getTitle(): string | ||
{ | ||
return 'Rename outdated plugins'; | ||
} | ||
|
||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function executeUpdate(): bool | ||
{ | ||
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('tt_content'); | ||
$result = $queryBuilder | ||
->update('tt_content') | ||
->where( | ||
$queryBuilder->expr()->eq('list_type', $queryBuilder->createNamedParameter(self::OLD_LIST_TYPE)), | ||
) | ||
->set('list_type', self::NEW_LIST_TYPE) | ||
->executeStatement(); | ||
return $result > 0; | ||
} | ||
|
||
public function updateNecessary(): bool | ||
{ | ||
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('tt_content'); | ||
$count = $queryBuilder | ||
->count('uid') | ||
->from('tt_content') | ||
->where( | ||
$queryBuilder->expr()->eq('list_type', $queryBuilder->createNamedParameter(self::OLD_LIST_TYPE)), | ||
) | ||
->executeQuery() | ||
->fetchOne(); | ||
return is_int($count) && $count > 0; | ||
} | ||
|
||
public function getPrerequisites(): array | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters