Initial commit - Typo3 11.5.41
This commit is contained in:
84
typo3conf/ext/news/Classes/Updates/NewsSlugUpdater.php
Normal file
84
typo3conf/ext/news/Classes/Updates/NewsSlugUpdater.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GeorgRinger\News\Updates;
|
||||
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
use GeorgRinger\News\Service\SlugService;
|
||||
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
|
||||
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
|
||||
|
||||
/**
|
||||
* Migrate empty slugs
|
||||
*/
|
||||
class NewsSlugUpdater implements UpgradeWizardInterface
|
||||
{
|
||||
const TABLE = 'tx_news_domain_model_news';
|
||||
|
||||
/** @var SlugService */
|
||||
protected $slugService;
|
||||
|
||||
/**
|
||||
* NewsSlugUpdater constructor.
|
||||
* @param SlugService $slugService
|
||||
*/
|
||||
public function __construct(
|
||||
SlugService $slugService
|
||||
) {
|
||||
$this->slugService = $slugService;
|
||||
}
|
||||
|
||||
public function executeUpdate(): bool
|
||||
{
|
||||
$this->slugService->performUpdates();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function updateNecessary(): bool
|
||||
{
|
||||
$elementCount = $this->slugService->countOfSlugUpdates();
|
||||
|
||||
return $elementCount > 0;
|
||||
}
|
||||
|
||||
public function getPrerequisites(): array
|
||||
{
|
||||
return [
|
||||
DatabaseUpdatedPrerequisite::class
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Updates slug field "path_segment" of EXT:news records';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description
|
||||
*
|
||||
* @return string Longer description of this updater
|
||||
*/
|
||||
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';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user