Skip to content

Instantly share code, notes, and snippets.

@kitzberger
Created March 29, 2022 08:57
Show Gist options
  • Select an option

  • Save kitzberger/9a374a155984cdfa29b8a8e318d300d4 to your computer and use it in GitHub Desktop.

Select an option

Save kitzberger/9a374a155984cdfa29b8a8e318d300d4 to your computer and use it in GitHub Desktop.
Populate slugs for a custom table (TYPO3 10+)
<?php
defined('TYPO3_MODE') || die ('Access denied.');
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['projectsSlugs'] = \Vendor\MyExtension\Updates\PopulateProjectSlugs::class;
<?php
declare(strict_types=1);
namespace Vendor\MyExtension\Updates;
use TYPO3\CMS\Install\Updates\PopulatePageSlugs;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
class PopulateProjectSlugs extends PopulatePageSlugs implements RepeatableInterface
{
/**
* @var string
*/
protected $table = 'tx_myextension_domain_model_project';
/**
* @var string
*/
protected $fieldName = 'slug';
/**
* @return string Unique identifier of this updater
*/
public function getIdentifier(): string
{
return 'projectsSlugs';
}
/**
* @return string Title of this updater
*/
public function getTitle(): string
{
return 'Introduce URL parts ("slugs") to all existing projects';
}
/**
* @return string Longer description of this updater
*/
public function getDescription(): string
{
return '';
}
/**
* Load the TCA field configuration for the slug field
* and add further static fields to generatorOptions.
*
* @return array
*/
protected function getSlugFieldConfig(): array
{
return $GLOBALS['TCA'][$this->table]['columns'][$this->fieldName]['config'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment