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>|null
- 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, mixed>
- Array of the elements to create edit forms for.
- $errorC : int
- Counter, used to count the number of errors (when users do not have edit permissions)
- $eventDispatcher : EventDispatcherInterface
- $firstEl : array<string|int, mixed>|null
- Pointer to the first element in $elementsData
- $formResultCompiler : FormResultCompiler
- $iconFactory : IconFactory
- $isPageInFreeTranslationMode : bool
- $isSavedRecord : bool
- True if a record has been saved
- $module : ModuleInterface|null
- $moduleProvider : ModuleProvider
- $moduleTemplateFactory : ModuleTemplateFactory
- $openDocumentRepository : OpenDocumentRepository
- $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
- ID for displaying the page in the frontend, "save and view"
- $R_URI : string
- Set to the URL of this script including variables which is needed to re-display the form.
- $R_URL_getvars : array<string|int, mixed>
- Contains $request query parameters. This array is the foundation for creating the R_URI internal var which becomes the url to which forms are submitted
- $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
- $storeArray : array<string|int, mixed>
- Contains an array with key/value pairs of GET parameters needed to reach the current document displayed - used in the 'open documents' toolbar.
- $storeTitle : string
- Is loaded with the "title" of the currently "open document" used for the open document toolbar
- $tcaSchemaFactory : TcaSchemaFactory
- $uriBuilder : UriBuilder
- $viewId : int
- Is set to the pid value of the last shown record - thus indicating which page to show when clicking the SAVE/VIEW button
Methods
- __construct() : mixed
- mainAction() : ResponseInterface
- Main dispatcher entry method registered as "record_edit" end point.
- addSlugFieldsToColumnsOnly() : void
- Always add required fields of slug field
- closeDocument() : ResponseInterface|null
- Handling the closing of a document and then creates a valid redirect
- compileStoreData() : array<string|int, mixed>
- The return value is used for the variable $this->storeArray to prepare 'open documents' urls
- createBreadcrumb() : void
- fixWSversioningInEditConf() : void
- 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>
- handleDocumentClosing() : void
- Close the current document(s).
- isInconsistentLanguageHandlingAllowed() : bool
- Return true if inconsistent language handling is allowed
- 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() : mixed
- 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() : string
- Creates the editing form with FormEngine, based on the input from GPvars.
- 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
- setIsPageInFreeTranslationMode() : void
- Set the boolean to check if the page is in free translation mode
- setModuleContext() : void
- shouldRedirectToEmptyPage() : bool
- storeCurrentDocumentInOpenDocuments() : void
- Store all currently edited records as open documents.
- 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>|null
$columnsOnly
= null
$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, mixed>
$elementsData
$errorC
Counter, used to count the number of errors (when users do not have edit permissions)
protected
int
$errorC
$eventDispatcher read-only
protected
EventDispatcherInterface
$eventDispatcher
$firstEl
Pointer to the first element in $elementsData
protected
array<string|int, mixed>|null
$firstEl
$formResultCompiler
protected
FormResultCompiler
$formResultCompiler
$iconFactory read-only
protected
IconFactory
$iconFactory
$isPageInFreeTranslationMode
protected
bool
$isPageInFreeTranslationMode
= false
$isSavedRecord
True if a record has been saved
protected
bool
$isSavedRecord
= false
$module
protected
ModuleInterface|null
$module
= null
$moduleProvider read-only
protected
ModuleProvider
$moduleProvider
$moduleTemplateFactory read-only
protected
ModuleTemplateFactory
$moduleTemplateFactory
$openDocumentRepository read-only
protected
OpenDocumentRepository
$openDocumentRepository
$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
ID for displaying the page in the frontend, "save and view"
protected
int
$popViewId
$R_URI
Set to the URL of this script including variables which is needed to re-display the form.
protected
string
$R_URI
$R_URL_getvars
Contains $request query parameters. This array is the foundation for creating the R_URI internal var which becomes the url to which forms are submitted
protected
array<string|int, mixed>
$R_URL_getvars
$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
$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
$storeArray
Contains an array with key/value pairs of GET parameters needed to reach the current document displayed - used in the 'open documents' toolbar.
protected
array<string|int, mixed>
$storeArray
= []
$storeTitle
Is loaded with the "title" of the currently "open document" used for the open document toolbar
protected
string
$storeTitle
= ''
$tcaSchemaFactory
protected
TcaSchemaFactory
$tcaSchemaFactory
$uriBuilder read-only
protected
UriBuilder
$uriBuilder
$viewId
Is set to the pid value of the last shown record - thus indicating which page to show when clicking the SAVE/VIEW button
protected
int
$viewId
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, TcaSchemaFactory $tcaSchemaFactory, OpenDocumentRepository $openDocumentRepository) : 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
- $tcaSchemaFactory : TcaSchemaFactory
- $openDocumentRepository : OpenDocumentRepository
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> $queryParams) : void
Parameters
- $queryParams : array<string|int, mixed>
closeDocument()
Handling the closing of a document and then creates a valid redirect
protected
closeDocument(FormAction $requestAction[, bool $allowRedirects = true ]) : ResponseInterface|null
Parameters
- $requestAction : FormAction
- $allowRedirects : bool = true
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>
Parameters
- $request : ServerRequestInterface
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>|null $mapArray = null ]) : void
Parameters
- $mapArray : array<string|int, mixed>|null = null
-
Mapping between old and new ids if auto-versioning has been performed.
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) : void
Parameters
- $view : ModuleTemplate
- $request : ServerRequestInterface
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() : PreviewUriBuilder
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 $theUid) : array<string|int, mixed>|false
Parameters
- $table : string
-
Table name
- $theUid : int
-
Record UID
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
Parameters
- $table : string
- $key : string
Return values
stringgetUrlQueryParamsForCurrentRequest()
protected
getUrlQueryParamsForCurrentRequest(ServerRequestInterface $request) : array<string|int, mixed>
Parameters
- $request : ServerRequestInterface
Return values
array<string|int, mixed>handleDocumentClosing()
Close the current document(s).
protected
handleDocumentClosing() : void
isInconsistentLanguageHandlingAllowed()
Return true if inconsistent language handling is allowed
protected
isInconsistentLanguageHandlingAllowed() : bool
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, string $table, int $uid[, int|null $pid = null ]) : mixed
Parameters
- $view : ModuleTemplate
- $table : string
-
Table name
- $uid : int
-
Uid for which to create a new language
- $pid : int|null = null
-
Pid of the record
makeEditForm()
Creates the editing form with FormEngine, based on the input from GPvars.
protected
makeEditForm(ServerRequestInterface $request, ModuleTemplate $view) : string
Parameters
- $request : ServerRequestInterface
- $view : ModuleTemplate
Return values
string —HTML form elements wrapped in tables
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) : void
Parameters
- $view : ModuleTemplate
- $position : string
- $group : int
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, int $sysLanguageUid, int $l18nParent) : void
Parameters
- $view : ModuleTemplate
- $position : string
- $group : int
- $sysLanguageUid : int
- $l18nParent : int
registerHistoryButtonToButtonBar()
Register the history button to the button bar
protected
registerHistoryButtonToButtonBar(ModuleTemplate $view, string $position, int $group) : void
Parameters
- $view : ModuleTemplate
- $position : string
- $group : int
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, int $sysLanguageUid, int $l18nParent) : void
Parameters
- $view : ModuleTemplate
- $position : string
- $group : int
- $sysLanguageUid : int
- $l18nParent : 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
stringsetIsPageInFreeTranslationMode()
Set the boolean to check if the page is in free translation mode
protected
setIsPageInFreeTranslationMode(array<string|int, mixed>|null $record, int $sysLanguageUid) : void
Parameters
- $record : array<string|int, mixed>|null
- $sysLanguageUid : int
setModuleContext()
protected
setModuleContext(ModuleTemplate $view) : void
Parameters
- $view : ModuleTemplate
shouldRedirectToEmptyPage()
protected
shouldRedirectToEmptyPage() : bool
Return values
boolstoreCurrentDocumentInOpenDocuments()
Store all currently edited records as open documents.
protected
storeCurrentDocumentInOpenDocuments() : void
Creates one document entry per record being edited.
updateInlineView()
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