Project

General

Profile

Actions

Task #91860

open

Simplify SlugHelper to make it actually useful

Added by Stefan P almost 4 years ago. Updated over 2 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Target version:
-
Start date:
2020-07-24
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Whenever one uses the SlugHelper (be it core code or 3rd party code) one has to do this copy-pasting afterwards:

        $state = RecordStateFactory::forName($table)
            ->fromArray($fullRecord, $realPid, $id);
        $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], true);
        if (in_array('unique', $evalCodesArray, true)) {
            $value = $helper->buildSlugForUniqueInTable($value, $state);
        }
        if (in_array('uniqueInSite', $evalCodesArray, true)) {
            $value = $helper->buildSlugForUniqueInSite($value, $state);
        }
        if (in_array('uniqueInPid', $evalCodesArray, true)) {
            $value = $helper->buildSlugForUniqueInPid($value, $state);
        }

This should happen implicitly in the generate() and sanitize() methods of the SlugHelper itself, because it has to happen anyways and the SlugHelper already has all needed parameters anyways...

Also the constructor should allow to pass null to $configuration (default it to $configuration = null) and in this case it should fetch the configuration automatically from the TCA. Then you don't need to access GLOBALS[TCA][table] whenever calling the SlugHelper with default configuration (because the slug helper gets the table and field name anyways and can fetch it automatically).

Actions #1

Updated by Stefan P over 2 years ago

  • TYPO3 Version changed from 9 to 10
Actions

Also available in: Atom PDF