Created
March 29, 2022 08:57
-
-
Save kitzberger/9a374a155984cdfa29b8a8e318d300d4 to your computer and use it in GitHub Desktop.
Populate slugs for a custom table (TYPO3 10+)
This file contains hidden or 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
| <?php | |
| defined('TYPO3_MODE') || die ('Access denied.'); | |
| $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['projectsSlugs'] = \Vendor\MyExtension\Updates\PopulateProjectSlugs::class; |
This file contains hidden or 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
| <?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