‪TYPO3CMS  ‪main
TYPO3\CMS\Backend\Controller\FormSlugAjaxController Class Reference
Inheritance diagram for TYPO3\CMS\Backend\Controller\FormSlugAjaxController:
TYPO3\CMS\Backend\Controller\AbstractFormEngineAjaxController

Public Member Functions

 __construct (private Context $context, private readonly HashService $hashService)
 
 suggestAction (ServerRequestInterface $request)
 

Protected Member Functions

 checkRequest (ServerRequestInterface $request)
 
- ‪Protected Member Functions inherited from ‪TYPO3\CMS\Backend\Controller\AbstractFormEngineAjaxController
 addJavaScriptModulesToJavaScriptItems (array $modules, JavaScriptItems $items)
 
string getRelativePathToStylesheetFile (string $stylesheetFile)
 
array getLabelsFromLocalizationFile (string $file)
 
 getLanguageService ()
 

Detailed Description

Handle FormEngine AJAX calls for Slug validation and sanitization

This class is a specific Backend controller implementation and is not considered part of the Public TYPO3 API.

Definition at line 38 of file FormSlugAjaxController.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Backend\Controller\FormSlugAjaxController::__construct ( private Context  $context,
private readonly HashService  $hashService 
)

Definition at line 40 of file FormSlugAjaxController.php.

Member Function Documentation

◆ checkRequest()

TYPO3\CMS\Backend\Controller\FormSlugAjaxController::checkRequest ( ServerRequestInterface  $request)
protected

◆ suggestAction()

TYPO3\CMS\Backend\Controller\FormSlugAjaxController::suggestAction ( ServerRequestInterface  $request)

Validates a given slug against the site and give a suggestion when it's already in use

For new records this will look like this:

  • ‪If "slug" field is empty, take the other fields, and generate the slug based on the sent fields.
    • ‪JS: adapt the "placeholder" value only, as on save the field will be filled with the value via DataHandler
  • ‪If "slug" field is not empty (= "unlocked" and manually typed in)
    • ‪sanitize the slug
      • ‪If 'uniqueInSite' is set check if it's unique for the site
        • ‪If not unique propose another slug and return this with the flag hasConflicts = true
      • ‪If 'uniqueInPid' is set check if it's unique for the pid
        • ‪If not unique propose another slug and return this with the flag hasConflicts = true

For existing records:

  • ‪sanitize the slug
    • ‪If 'uniqueInSite' is set check if it's unique for the site
      • ‪If not unique propose another slug and return this with the flag hasConflicts = true
    • ‪If 'uniqueInPid' is set check if it's unique for the pid
      • ‪If not unique propose another slug and return this with the flag hasConflicts = true
    • ‪If the slug has changed from the existing database record (
      Todo:
      ‪)
      • ‪Show a message that the old URL will stop working (possibly add a redirect via checkbox)
      • ‪If the page has subpages, show a warning that the subpages WILL NOT BE MODIFIED and keep the OLD url
Parameters
ServerRequestInterface$request
Exceptions

Definition at line 71 of file FormSlugAjaxController.php.

References $GLOBALS, TYPO3\CMS\Backend\Controller\FormSlugAjaxController\checkRequest(), TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory\forName(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().