#91860Simplify SlugHelper to make it actually useful
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).
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch
- Commit message
-
[TASK] Simplify SlugHelper to make it actually useful Resolves: #91860 Releases: main