EditDocumentController

class \TYPO3\CMS\Backend\Controller\EditDocumentController

Main backend controller almost always used if some database record is edited in the backend.

Main job of this controller is to evaluate and sanitize $request parameters, call the DataHandler if records should be created or updated and execute FormEngine for record rendering.

Attributes

#[AsController]

Table of Contents

Properties

$addRecordWizardParameters  : array<string, mixed>|null
Set by processData() when a "_savedokaddrecord" request resolved the real, now-persisted uid of a record that was still new when its own "+ add related record" wizard link was clicked; mainAction() redirects to Wizard/AddController with these parameters instead of the normal post-save destination when set.
$backendEntryPointResolver  : BackendEntryPointResolver
$breadcrumbFactory  : BreadcrumbFactory
$columnsOnly  : array
Array of tables with a lists of field names to edit for those tables. If specified, only those fields will be rendered. Otherwise, all (available) fields in the record are shown according to the TCA type.
$defVals  : array|null
Default values for fields
$editconf  : array<string, mixed>
An array looking approx like [tablename][list-of-ids]=command, eg. "&edit[pages][123]=edit".
$elementsData  : FormElementData[]
Array of the elements to create edit forms for.
$eventDispatcher  : EventDispatcherInterface
$firstEl  : FormElementData|null
Pointer to the first element in $elementsData
$flashMessageService  : FlashMessageService
$iconFactory  : IconFactory
$localizationRepository  : LocalizationRepository
$module  : ModuleInterface|null
$moduleProvider  : ModuleProvider
$moduleTemplateFactory  : ModuleTemplateFactory
$numberOfErrors  : int
Counter, used to count the number of errors (when users do not have edit permissions)
$overrideVals  : array|null
Array of values to force being set as hidden fields in FormEngine
$pageinfo  : array
$pageRenderer  : PageRenderer
$popViewId  : int
The preview page id.
$recordFactory  : RecordFactory
$resourceFactory  : ResourceFactory
$retUrl  : string
Prepared return URL. Contains the URL that we should return to from FormEngine if close button is clicked. Usually passed along as 'returnUrl', but falls back to "dummy" action.
$returnEditConf  : bool
If true, $this->editconf array is added a redirect response, used by Wizard/AddController
$returnNewPageId  : bool
Boolean: If set, then the GET var "&id=" will be added to the retUrl string so that the NEW id of something is returned to the script calling the form.
$returnUrl  : string|null
If set, this value will be set in $this->retUrl as "returnUrl", if not, $this->retUrl will link to dummy action
$tcaSchemaFactory  : TcaSchemaFactory
$uriBuilder  : UriBuilder

Methods

__construct()  : mixed
mainAction()  : ResponseInterface
Main dispatcher entry method registered as "record_edit" end point.
addSlugFieldsToColumnsOnly()  : array
Always add required fields of slug field
closeAndPossiblyRedirectAction()  : ResponseInterface|null
Called when someone is done finishing editing - either by just hitting "close" or "save + close", but also for New/AddController when using returnEditConf.
compileStoreData()  : array
The return value is used for the variable $this->storeArray to prepare 'open documents' urls
createBreadcrumb()  : void
fixWSversioningInEditConf()  : array
Fix $this->editconf if versioning applies to any of the records
getBackendUser()  : BackendUserAuthentication
getButtons()  : void
Create the panel of buttons for submitting the form or otherwise perform operations.
getCloseUrl()  : string
Returns the URL (usually for the "returnUrl") which closes the current window.
getConnectedContentElementTranslationsCount()  : int
Get the count of connected translated content elements
getDisableDelete()  : bool
Returns if delete for the current table is disabled by configuration.
getFreeTranslationMode()  : bool
True if the page is in free translation mode.
getInfobox()  : string
Helper function for rendering an Infobox
getLanguages()  : array
Returns languages available for record translations on given page.
getLanguageService()  : LanguageService
getPreviewUriBuilderForRecordPreview()  : PreviewUriBuilder
getQueryBuilderForTranslationMode()  : QueryBuilder
Get the query builder for the translation mode
getRecordForEdit()  : array|false
Get record for editing.
getStandAloneContentElementTranslationsCount()  : int
Get the count of standalone translated content elements
getTsConfigOption()  : string
Get a TSConfig 'option.' array, possibly for a specific table.
getUrlQueryParamsForCurrentRequest()  : array
isInconsistentLanguageHandlingAllowed()  : bool
Return true if inconsistent language handling is allowed
isPageContentFreeTranslationMode()  : bool
Checks if the page is in free translation mode for tt_content
isRecordCurrentBackendUser()  : bool
Return true in case the current record is the current backend user
isSingleRecordView()  : bool
Whether a single record view is requested. This means, only one element exists in $elementsData.
languageSwitch()  : void
Make selector box for creating new translation for a record or switching to edit the record in an existing language. Displays only languages which are available for the current page.
makeEditForm()  : FormResultCollection
Creates the editing form with FormEngine, based on the input from GPvars.
openCurrentDocuments()  : void
Notify extensions that document(s) have been opened for editing.
prepareColumnsOnlyConfigurationFromRequest()  : array
processData()  : void
Do processing of data, submitting it to DataHandler.
registerCloseButtonToButtonBar()  : void
Register the close button to the button bar
registerColumnsOnlyButtonToButtonBar()  : void
Register "Edit whole record" button to the button bar
registerDeleteButtonToButtonBar()  : void
Register the delete button to the button bar
registerDuplicationButtonToButtonBar()  : void
Register the duplication button to the button bar
registerHistoryButtonToButtonBar()  : void
Register the history button to the button bar
registerInfoButtonToButtonBar()  : void
Register the info button to the button bar
registerNewButtonToButtonBar()  : void
Register the new button to the button bar
registerOpenInNewWindowButtonToButtonBar()  : void
Register the open in new window button to the button bar
registerShortcutButtonToButtonBar()  : void
Register the shortcut button to the button bar
registerViewButtonToButtonBar()  : void
Register the view button to the button bar
resolveDefaultReturnUrl()  : string
resolveDocumentTitle()  : string
Resolves the document title used for the browser tab and shortcut.
sanitizeEditConf()  : array
setModuleContext()  : void
shouldRedirectToEmptyPage()  : bool
updateInlineView()  : void
Update expanded/collapsed states on new inline records if any within backendUser->uc.

Properties

$addRecordWizardParameters

Set by processData() when a "_savedokaddrecord" request resolved the real, now-persisted uid of a record that was still new when its own "+ add related record" wizard link was clicked; mainAction() redirects to Wizard/AddController with these parameters instead of the normal post-save destination when set.

protected array<string, mixed>|null $addRecordWizardParameters = null

$columnsOnly

Array of tables with a lists of field names to edit for those tables. If specified, only those fields will be rendered. Otherwise, all (available) fields in the record are shown according to the TCA type.

protected array $columnsOnly = []

$defVals

Default values for fields

protected array|null $defVals

[table][field]

$editconf

An array looking approx like [tablename][list-of-ids]=command, eg. "&edit[pages][123]=edit".

protected array<string, mixed> $editconf = []

$eventDispatcher read-only

protected EventDispatcherInterface $eventDispatcher

$numberOfErrors

Counter, used to count the number of errors (when users do not have edit permissions)

protected int $numberOfErrors = 0

$overrideVals

Array of values to force being set as hidden fields in FormEngine

protected array|null $overrideVals

[table][field]

$popViewId

The preview page id.

protected int $popViewId = 0

ID for displaying the page in the frontend, "save and view" Is set to the pid value of the last shown record from "viewId" - thus indicating which page to show when clicking the SAVE/VIEW button and transferred via GET/POST parameter "popViewId"

$retUrl

Prepared return URL. Contains the URL that we should return to from FormEngine if close button is clicked. Usually passed along as 'returnUrl', but falls back to "dummy" action.

protected string $retUrl

$returnEditConf

If true, $this->editconf array is added a redirect response, used by Wizard/AddController

protected bool $returnEditConf = false

$returnNewPageId

Boolean: If set, then the GET var "&id=" will be added to the retUrl string so that the NEW id of something is returned to the script calling the form.

protected bool $returnNewPageId = false

$returnUrl

If set, this value will be set in $this->retUrl as "returnUrl", if not, $this->retUrl will link to dummy action

protected string|null $returnUrl

Methods

__construct()

public __construct(ComponentFactory $componentFactory, EventDispatcherInterface $eventDispatcher, IconFactory $iconFactory, RecordFactory $recordFactory, BreadcrumbFactory $breadcrumbFactory, PageRenderer $pageRenderer, UriBuilder $uriBuilder, ModuleTemplateFactory $moduleTemplateFactory, BackendEntryPointResolver $backendEntryPointResolver, ModuleProvider $moduleProvider, FormDataCompiler $formDataCompiler, NodeFactory $nodeFactory, FormResultFactory $formResultFactory, FormResultHandler $formResultHandler, TcaSchemaFactory $tcaSchemaFactory, LocalizationRepository $localizationRepository, ResourceFactory $resourceFactory, FlashMessageService $flashMessageService, RecordIdentityRenderer $recordIdentityRenderer, RecordTypeLabelResolver $recordTypeLabelResolver) : mixed

Parameters

$componentFactory : ComponentFactory
$eventDispatcher : EventDispatcherInterface
$iconFactory : IconFactory
$recordFactory : RecordFactory
$breadcrumbFactory : BreadcrumbFactory
$pageRenderer : PageRenderer
$uriBuilder : UriBuilder
$moduleTemplateFactory : ModuleTemplateFactory
$backendEntryPointResolver : BackendEntryPointResolver
$moduleProvider : ModuleProvider
$formDataCompiler : FormDataCompiler
$nodeFactory : NodeFactory
$formResultFactory : FormResultFactory
$formResultHandler : FormResultHandler
$tcaSchemaFactory : TcaSchemaFactory
$localizationRepository : LocalizationRepository
$resourceFactory : ResourceFactory
$flashMessageService : FlashMessageService
$recordIdentityRenderer : RecordIdentityRenderer
$recordTypeLabelResolver : RecordTypeLabelResolver

addSlugFieldsToColumnsOnly()

Always add required fields of slug field

protected addSlugFieldsToColumnsOnly(array $finalColumnsOnly, array $tables) : array

Parameters

$finalColumnsOnly : array
$tables : array

Return values

array

closeAndPossiblyRedirectAction()

Called when someone is done finishing editing - either by just hitting "close" or "save + close", but also for New/AddController when using returnEditConf.

protected closeAndPossiblyRedirectAction(FormAction $requestAction) : ResponseInterface|null

At this time, "closing" open documents in the session and unlocking should be done already.

Parameters

$requestAction : FormAction

Return values

ResponseInterface|null —

Redirect response if needed

compileStoreData()

The return value is used for the variable $this->storeArray to prepare 'open documents' urls

protected compileStoreData(ServerRequestInterface $request, array $overriddenValues) : array

Parameters

$request : ServerRequestInterface
$overriddenValues : array

Return values

array

fixWSversioningInEditConf()

Fix $this->editconf if versioning applies to any of the records

protected fixWSversioningInEditConf(array $editConf[, array|null $mapArray = null ]) : array

Parameters

$editConf : array
$mapArray : array|null = null

Mapping between old and new ids if auto-versioning has been performed.

Return values

array

getButtons()

Create the panel of buttons for submitting the form or otherwise perform operations.

protected getButtons(ModuleTemplate $view, ServerRequestInterface $request, FormElementData|null $mainFormElement, UriInterface $currentEditingUrl, string $documentTitle) : void

Parameters

$view : ModuleTemplate
$request : ServerRequestInterface
$mainFormElement : FormElementData|null
$currentEditingUrl : UriInterface
$documentTitle : string

getCloseUrl()

Returns the URL (usually for the "returnUrl") which closes the current window.

protected getCloseUrl(ServerRequestInterface $request) : string

Used when editing a record in a popup.

Parameters

$request : ServerRequestInterface

Return values

string

getConnectedContentElementTranslationsCount()

Get the count of connected translated content elements

protected getConnectedContentElementTranslationsCount(int $page, int $column, int $language) : int

Parameters

$page : int
$column : int
$language : int

Return values

int

getDisableDelete()

Returns if delete for the current table is disabled by configuration.

protected getDisableDelete() : bool

For sys_file_metadata in default language delete is always disabled.

Return values

bool

getFreeTranslationMode()

True if the page is in free translation mode.

protected getFreeTranslationMode(int $page, int $column, int $language) : bool

Parameters

$page : int
$column : int
$language : int

Return values

bool

getInfobox()

Helper function for rendering an Infobox

protected getInfobox(string $message[, string|null $title = null ]) : string

Parameters

$message : string
$title : string|null = null

Return values

string

getLanguages()

Returns languages available for record translations on given page.

protected getLanguages(int $id, string $table) : array

Parameters

$id : int

Page id: If zero, all available system languages will be returned. If set to another value, only languages, a page translation exists for, will be returned.

$table : string

For pages we want all languages, for other records the languages of the page translations

Return values

array —

Array with languages (uid, title, ISOcode, flagIcon)

getQueryBuilderForTranslationMode()

Get the query builder for the translation mode

protected getQueryBuilderForTranslationMode(int $page, int $column, int $language) : QueryBuilder

Parameters

$page : int
$column : int
$language : int

Return values

QueryBuilder

getRecordForEdit()

Get record for editing.

protected getRecordForEdit(string $table, int $recordId) : array|false

Parameters

$table : string
$recordId : int

Return values

array|false —

Returns record to edit, false if none

getStandAloneContentElementTranslationsCount()

Get the count of standalone translated content elements

protected getStandAloneContentElementTranslationsCount(int $page, int $column, int $language) : int

Parameters

$page : int
$column : int
$language : int

Return values

int

getTsConfigOption()

Get a TSConfig 'option.' array, possibly for a specific table.

protected getTsConfigOption(string $table, string $key[, string $defaultValue = '' ]) : string

Parameters

$table : string
$key : string
$defaultValue : string = ''

Return values

string

getUrlQueryParamsForCurrentRequest()

protected getUrlQueryParamsForCurrentRequest(ServerRequestInterface $request) : array

Parameters

$request : ServerRequestInterface

Return values

array

isInconsistentLanguageHandlingAllowed()

Return true if inconsistent language handling is allowed

protected isInconsistentLanguageHandlingAllowed() : bool

Return values

bool

isPageContentFreeTranslationMode()

Checks if the page is in free translation mode for tt_content

protected isPageContentFreeTranslationMode(FormElementData $formElementData, int $languageId) : bool

Parameters

$formElementData : FormElementData
$languageId : int

Return values

bool

isRecordCurrentBackendUser()

Return true in case the current record is the current backend user

protected isRecordCurrentBackendUser() : bool

Return values

bool

isSingleRecordView()

Whether a single record view is requested. This means, only one element exists in $elementsData.

protected isSingleRecordView() : bool

Return values

bool

languageSwitch()

Make selector box for creating new translation for a record or switching to edit the record in an existing language. Displays only languages which are available for the current page.

protected languageSwitch(ModuleTemplate $view, FormElementData $formElement) : void

Parameters

$view : ModuleTemplate
$formElement : FormElementData

makeEditForm()

Creates the editing form with FormEngine, based on the input from GPvars.

protected makeEditForm(ServerRequestInterface $request, ModuleTemplate $view, UriInterface $currentRequestUrl) : FormResultCollection

Parameters

$request : ServerRequestInterface
$view : ModuleTemplate
$currentRequestUrl : UriInterface

Return values

FormResultCollection —

Form result objects

openCurrentDocuments()

Notify extensions that document(s) have been opened for editing.

protected openCurrentDocuments() : void

Dispatches one event per record being opened.

prepareColumnsOnlyConfigurationFromRequest()

protected prepareColumnsOnlyConfigurationFromRequest(ServerRequestInterface $request) : array

Parameters

$request : ServerRequestInterface

Return values

array

processData()

Do processing of data, submitting it to DataHandler.

protected processData(ModuleTemplate $view, ServerRequestInterface $request) : void

Also handles the "duplication" of a record.

Parameters

$view : ModuleTemplate
$request : ServerRequestInterface

registerCloseButtonToButtonBar()

Register the close button to the button bar

protected registerCloseButtonToButtonBar(ModuleTemplate $view, string $position, int $group) : void

Parameters

$view : ModuleTemplate
$position : string
$group : int

registerColumnsOnlyButtonToButtonBar()

Register "Edit whole record" button to the button bar

protected registerColumnsOnlyButtonToButtonBar(ModuleTemplate $view, string $position, int $group, UriInterface $currentEditingUrl) : void

Parameters

$view : ModuleTemplate
$position : string
$group : int
$currentEditingUrl : UriInterface

registerDeleteButtonToButtonBar()

Register the delete button to the button bar

protected registerDeleteButtonToButtonBar(ModuleTemplate $view, string $position, int $group, ServerRequestInterface $request) : void

Parameters

$view : ModuleTemplate
$position : string
$group : int
$request : ServerRequestInterface

registerDuplicationButtonToButtonBar()

Register the duplication button to the button bar

protected registerDuplicationButtonToButtonBar(ModuleTemplate $view, string $position, int $group) : void

Parameters

$view : ModuleTemplate
$position : string
$group : int

registerHistoryButtonToButtonBar()

Register the history button to the button bar

protected registerHistoryButtonToButtonBar(ModuleTemplate $view, string $position, int $group, UriInterface $currentEditingUrl) : void

Parameters

$view : ModuleTemplate
$position : string
$group : int
$currentEditingUrl : UriInterface

registerInfoButtonToButtonBar()

Register the info button to the button bar

protected registerInfoButtonToButtonBar(ModuleTemplate $view, string $position, int $group) : void

Parameters

$view : ModuleTemplate
$position : string
$group : int

registerNewButtonToButtonBar()

Register the new button to the button bar

protected registerNewButtonToButtonBar(ModuleTemplate $view, string $position, int $group) : void

Parameters

$view : ModuleTemplate
$position : string
$group : int

registerOpenInNewWindowButtonToButtonBar()

Register the open in new window button to the button bar

protected registerOpenInNewWindowButtonToButtonBar(ModuleTemplate $view, string $position, int $group, ServerRequestInterface $request) : void

Parameters

$view : ModuleTemplate
$position : string
$group : int
$request : ServerRequestInterface

registerShortcutButtonToButtonBar()

Register the shortcut button to the button bar

protected registerShortcutButtonToButtonBar(ModuleTemplate $view, ServerRequestInterface $request, string $documentTitle) : void

Parameters

$view : ModuleTemplate
$request : ServerRequestInterface
$documentTitle : string

registerViewButtonToButtonBar()

Register the view button to the button bar

protected registerViewButtonToButtonBar(ModuleTemplate $view, string $position, int $group) : void

Parameters

$view : ModuleTemplate
$position : string
$group : int

resolveDefaultReturnUrl()

protected resolveDefaultReturnUrl() : string

Return values

string

resolveDocumentTitle()

Resolves the document title used for the browser tab and shortcut.

protected resolveDocumentTitle(LanguageService $languageService) : string

Examples:

  • No form: "Edit form could not be loaded"
  • New record: "Create new {table}"
  • Single record: "{record title} · {table} · #{uid}"
  • Record with subtype: "{record title} · {subtype} · #{uid}"
  • Multiple records: "Edit multiple · {table} · N records"

Parameters

$languageService : LanguageService

Return values

string

sanitizeEditConf()

protected sanitizeEditConf(array $editConf) : array

Parameters

$editConf : array

Return values

array

shouldRedirectToEmptyPage()

protected shouldRedirectToEmptyPage() : bool

Return values

bool

updateInlineView()

Update expanded/collapsed states on new inline records if any within backendUser->uc.

protected updateInlineView(array|null $uc, DataHandler $dataHandler) : void

Parameters

$uc : array|null

The uc array to be processed and saved - uc[inlineView][...]

$dataHandler : DataHandler

Instance of DataHandler that saved data before

On this page