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
- $backendEntryPointResolver : BackendEntryPointResolver
- $breadcrumbFactory : BreadcrumbFactory
- $columnsOnly : array<string|int, mixed>
- 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<string|int, mixed>|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 : array<string|int, FormElementData>
- Array of the elements to create edit forms for.
- $eventDispatcher : EventDispatcherInterface
- $firstEl : FormElementData|null
- Pointer to the first element in $elementsData
- $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<string|int, mixed>|null
- Array of values to force being set as hidden fields in FormEngine
- $pageinfo : array<string|int, mixed>
- $pageRenderer : PageRenderer
- $popViewId : int
- The preview page id.
- $recordFactory : RecordFactory
- $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<string|int, mixed>
- 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<string|int, mixed>
- The return value is used for the variable $this->storeArray to prepare 'open documents' urls
- createBreadcrumb() : void
- fixWSversioningInEditConf() : array<string|int, mixed>
- 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<string|int, mixed>
- 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<string|int, mixed>|false
- Get record for editing.
- getShortcutTitle() : string
- Returns the shortcut title for the current element
- getStandAloneContentElementTranslationsCount() : int
- Get the count of standalone translated content elements
- getTsConfigOption() : string
- Get a TSConfig 'option.' array, possibly for a specific table.
- getUrlQueryParamsForCurrentRequest() : array<string|int, mixed>
- 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<string|int, mixed>
- 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
- sanitizeEditConf() : array<string|int, mixed>
- setModuleContext() : void
- shouldRedirectToEmptyPage() : bool
- updateInlineView() : void
- Update expanded/collapsed states on new inline records if any within backendUser->uc.
Properties
$backendEntryPointResolver read-only
protected
BackendEntryPointResolver
$backendEntryPointResolver
$breadcrumbFactory read-only
protected
BreadcrumbFactory
$breadcrumbFactory
$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<string|int, mixed>
$columnsOnly
= []
$defVals
Default values for fields
protected
array<string|int, mixed>|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
= []
$elementsData
Array of the elements to create edit forms for.
protected
array<string|int, FormElementData>
$elementsData
= []
$eventDispatcher read-only
protected
EventDispatcherInterface
$eventDispatcher
$firstEl
Pointer to the first element in $elementsData
protected
FormElementData|null
$firstEl
= null
$iconFactory read-only
protected
IconFactory
$iconFactory
$localizationRepository read-only
protected
LocalizationRepository
$localizationRepository
$module
protected
ModuleInterface|null
$module
= null
$moduleProvider read-only
protected
ModuleProvider
$moduleProvider
$moduleTemplateFactory read-only
protected
ModuleTemplateFactory
$moduleTemplateFactory
$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<string|int, mixed>|null
$overrideVals
[table][field]
$pageinfo
protected
array<string|int, mixed>
$pageinfo
$pageRenderer read-only
protected
PageRenderer
$pageRenderer
$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"
$recordFactory read-only
protected
RecordFactory
$recordFactory
$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
$tcaSchemaFactory
protected
TcaSchemaFactory
$tcaSchemaFactory
$uriBuilder read-only
protected
UriBuilder
$uriBuilder
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) : 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
mainAction()
Main dispatcher entry method registered as "record_edit" end point.
public
mainAction(ServerRequestInterface $request) : ResponseInterface
Parameters
- $request : ServerRequestInterface
Return values
ResponseInterfaceaddSlugFieldsToColumnsOnly()
Always add required fields of slug field
protected
addSlugFieldsToColumnsOnly(array<string|int, mixed> $finalColumnsOnly, array<string|int, mixed> $tables) : array<string|int, mixed>
Parameters
- $finalColumnsOnly : array<string|int, mixed>
- $tables : array<string|int, mixed>
Return values
array<string|int, mixed>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<string|int, mixed> $overriddenValues) : array<string|int, mixed>
Parameters
- $request : ServerRequestInterface
- $overriddenValues : array<string|int, mixed>
Return values
array<string|int, mixed>createBreadcrumb()
protected
createBreadcrumb(ModuleTemplate $view) : void
Parameters
- $view : ModuleTemplate
fixWSversioningInEditConf()
Fix $this->editconf if versioning applies to any of the records
protected
fixWSversioningInEditConf(array<string|int, mixed> $editConf[, array<string|int, mixed>|null $mapArray = null ]) : array<string|int, mixed>
Parameters
- $editConf : array<string|int, mixed>
- $mapArray : array<string|int, mixed>|null = null
-
Mapping between old and new ids if auto-versioning has been performed.
Return values
array<string|int, mixed>getBackendUser()
protected
getBackendUser() : BackendUserAuthentication
Return values
BackendUserAuthenticationgetButtons()
Create the panel of buttons for submitting the form or otherwise perform operations.
protected
getButtons(ModuleTemplate $view, ServerRequestInterface $request, FormElementData|null $mainFormElement, UriInterface $currentEditingUrl) : void
Parameters
- $view : ModuleTemplate
- $request : ServerRequestInterface
- $mainFormElement : FormElementData|null
- $currentEditingUrl : UriInterface
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
stringgetConnectedContentElementTranslationsCount()
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
intgetDisableDelete()
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
boolgetFreeTranslationMode()
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
boolgetInfobox()
Helper function for rendering an Infobox
protected
getInfobox(string $message[, string|null $title = null ]) : string
Parameters
- $message : string
- $title : string|null = null
Return values
stringgetLanguages()
Returns languages available for record translations on given page.
protected
getLanguages(int $id, string $table) : array<string|int, mixed>
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<string|int, mixed> —Array with languages (uid, title, ISOcode, flagIcon)
getLanguageService()
protected
getLanguageService() : LanguageService
Return values
LanguageServicegetPreviewUriBuilderForRecordPreview()
protected
getPreviewUriBuilderForRecordPreview(mixed $pageId) : PreviewUriBuilder
Parameters
- $pageId : mixed
Return values
PreviewUriBuildergetQueryBuilderForTranslationMode()
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
QueryBuildergetRecordForEdit()
Get record for editing.
protected
getRecordForEdit(string $table, int $recordId) : array<string|int, mixed>|false
Parameters
- $table : string
- $recordId : int
Return values
array<string|int, mixed>|false —Returns record to edit, false if none
getShortcutTitle()
Returns the shortcut title for the current element
protected
getShortcutTitle(ServerRequestInterface $request) : string
Parameters
- $request : ServerRequestInterface
Return values
stringgetStandAloneContentElementTranslationsCount()
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
intgetTsConfigOption()
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
stringgetUrlQueryParamsForCurrentRequest()
protected
getUrlQueryParamsForCurrentRequest(ServerRequestInterface $request) : array<string|int, mixed>
Parameters
- $request : ServerRequestInterface
Return values
array<string|int, mixed>isInconsistentLanguageHandlingAllowed()
Return true if inconsistent language handling is allowed
protected
isInconsistentLanguageHandlingAllowed() : bool
Return values
boolisPageContentFreeTranslationMode()
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
boolisRecordCurrentBackendUser()
Return true in case the current record is the current backend user
protected
isRecordCurrentBackendUser() : bool
Return values
boolisSingleRecordView()
Whether a single record view is requested. This means, only one element exists in $elementsData.
protected
isSingleRecordView() : bool
Return values
boollanguageSwitch()
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<string|int, mixed>
Parameters
- $request : ServerRequestInterface
Return values
array<string|int, mixed>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) : void
Parameters
- $view : ModuleTemplate
- $request : ServerRequestInterface
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
stringsanitizeEditConf()
protected
sanitizeEditConf(array<string|int, mixed> $editConf) : array<string|int, mixed>
Parameters
- $editConf : array<string|int, mixed>
Return values
array<string|int, mixed>setModuleContext()
protected
setModuleContext(ModuleTemplate $view) : void
Parameters
- $view : ModuleTemplate
shouldRedirectToEmptyPage()
protected
shouldRedirectToEmptyPage() : bool
Return values
boolupdateInlineView()
Update expanded/collapsed states on new inline records if any within backendUser->uc.
protected
updateInlineView(array<string|int, mixed>|null $uc, DataHandler $dataHandler) : void
Parameters
- $uc : array<string|int, mixed>|null
-
The uc array to be processed and saved - uc[inlineView][...]
- $dataHandler : DataHandler
-
Instance of DataHandler that saved data before