WorkspaceService implements SingletonInterface
Workspace service
Table of Contents
Interfaces
- SingletonInterface
- "empty" interface for singletons (marker interface pattern)
Constants
- LIVE_WORKSPACE_ID = 0
- TABLE_WORKSPACE = 'sys_workspace'
Properties
- $pagesWithVersionsInTable : array<string|int, mixed>
- $versionsOnPageCache : array<string|int, mixed>
Methods
- getAvailableWorkspaces() : array<string|int, mixed>
- retrieves the available workspaces from the database and checks whether they're available to the current BE user
- getCmdArrayForFlushWS() : array<string|int, mixed>
- Building DataHandler CMD-array for releasing all versions in a workspace.
- getCmdArrayForPublishWS() : array<string|int, mixed>
- Building DataHandler CMD-array for publishing all versions in a workspace.
- getCurrentWorkspace() : int
- Gets the current workspace ID.
- getPagesWithVersionsInTable() : array<string|int, mixed>
- Gets all pages that have workspace versions per table.
- getPreviewLinkLifetime() : int
- easy function to just return the number of hours.
- getWorkspaceTitle() : string
- Find the title for the requested workspace.
- hasPageRecordVersions() : bool
- Determines whether a page has workspace versions.
- isNewPage() : bool
- Determine whether a specific page is new and not yet available in the LIVE workspace
- selectVersionsInWorkspace() : array<string|int, mixed>
- Select all records from workspace pending for publishing Used from backend to display workspace overview User for auto-publishing for selecting versions for publication
- fetchPagesWithVersionsInTable() : array<string|int, mixed>
- Gets all pages that have workspace versions in a particular table.
- filterPermittedElements() : array<string|int, mixed>
- Remove all records which are not permitted for the user
- getBackendUser() : BackendUserAuthentication
- getLanguageService() : LanguageService
- getMovedRecordsFromPages() : array<string|int, mixed>
- Find all moved records at their new position.
- getNewVersionsForPages() : array<string|int, mixed>
- Find all versionized elements which are new (= do not have a live counterpart), so this method does not need to have a JOIN SQL statement.
- getPageChildrenRecursive() : array<string|int, int>
- Recursively fetch all children of a given page
- getTreeUids() : string
- Find all page uids recursive starting from a specific page
- isLanguageAccessibleForCurrentUser() : bool
- Check current be users language access on given record.
- isPageAccessibleForCurrentUser() : bool
- Checking access to the page the record is on, respecting ignored root level restrictions
- selectAllVersionsFromPages() : array<string|int, mixed>
- Find all versionized elements except moved and new records.
Constants
LIVE_WORKSPACE_ID
public
mixed
LIVE_WORKSPACE_ID
= 0
TABLE_WORKSPACE
public
mixed
TABLE_WORKSPACE
= 'sys_workspace'
Properties
$pagesWithVersionsInTable
protected
array<string|int, mixed>
$pagesWithVersionsInTable
= []
$versionsOnPageCache
protected
array<string|int, mixed>
$versionsOnPageCache
= []
Methods
getAvailableWorkspaces()
retrieves the available workspaces from the database and checks whether they're available to the current BE user
public
getAvailableWorkspaces() : array<string|int, mixed>
Return values
array<string|int, mixed> —array of workspaces available to the current user
getCmdArrayForFlushWS()
Building DataHandler CMD-array for releasing all versions in a workspace.
public
getCmdArrayForFlushWS(int $wsid[, bool $flush = true ][, int $pageId = 0 ][, int $language = null ]) : array<string|int, mixed>
Parameters
- $wsid : int
-
Real workspace ID, cannot be ONLINE (zero).
- $flush : bool = true
-
Run Flush (TRUE) or ClearWSID (FALSE) command
- $pageId : int = 0
-
The page id
- $language : int = null
-
Select specific language only
Return values
array<string|int, mixed> —Command array for DataHandler
getCmdArrayForPublishWS()
Building DataHandler CMD-array for publishing all versions in a workspace.
public
getCmdArrayForPublishWS(int $wsid[, bool $_ = false ][, int $pageId = 0 ][, int|null $language = null ]) : array<string|int, mixed>
Parameters
- $wsid : int
-
Real workspace ID, cannot be ONLINE (zero).
- $_ : bool = false
-
Unused, previously used to choose between swapping and publishing
- $pageId : int = 0
-
The page id
- $language : int|null = null
-
Select specific language only
Return values
array<string|int, mixed> —Command array for DataHandler
getCurrentWorkspace()
Gets the current workspace ID.
public
getCurrentWorkspace() : int
Return values
intgetPagesWithVersionsInTable()
Gets all pages that have workspace versions per table.
public
getPagesWithVersionsInTable(int $workspaceId) : array<string|int, mixed>
Result: [ 'sys_template' => [], 'tt_content' => [ 1 => true, 11 => true, 13 => true, 15 => true ], 'tx_something => [ 15 => true, 11 => true, 21 => true ], ]
Parameters
- $workspaceId : int
Return values
array<string|int, mixed>getPreviewLinkLifetime()
easy function to just return the number of hours.
public
getPreviewLinkLifetime() : int
a preview link is valid, based on the workspaces' custom value (default to 48 hours) or falls back to the users' TSconfig value "options.workspaces.previewLinkTTLHours".
by default, it's 48hs.
Return values
int —The hours as a number
getWorkspaceTitle()
Find the title for the requested workspace.
public
getWorkspaceTitle(int $wsId) : string
Parameters
- $wsId : int
Tags
Return values
stringhasPageRecordVersions()
Determines whether a page has workspace versions.
public
hasPageRecordVersions(int $workspaceId, int $pageId) : bool
Parameters
- $workspaceId : int
- $pageId : int
Return values
boolisNewPage()
Determine whether a specific page is new and not yet available in the LIVE workspace
public
isNewPage(int $id[, int $language = 0 ]) : bool
Parameters
- $id : int
-
Primary key of the page to check
- $language : int = 0
-
Language for which to check the page
Return values
boolselectVersionsInWorkspace()
Select all records from workspace pending for publishing Used from backend to display workspace overview User for auto-publishing for selecting versions for publication
public
selectVersionsInWorkspace(int $wsid[, int $stage = -99 ][, int $pageId = -1 ][, int $recursionLevel = 0 ][, string $selectionType = 'tables_select' ][, int $language = null ]) : array<string|int, mixed>
Parameters
- $wsid : int
-
Workspace ID. If -99, will select ALL versions from ANY workspace. If -98 will select all but ONLINE. >=-1 will select from the actual workspace
- $stage : int = -99
-
Stage filter: -99 means no filtering, otherwise it will be used to select only elements with that stage. For publishing, that would be "10
- $pageId : int = -1
-
Page id: Live page for which to find versions in workspace!
- $recursionLevel : int = 0
-
Recursion Level - select versions recursive - parameter is only relevant if $pageId != -1
- $selectionType : string = 'tables_select'
-
How to collect records for "listing" or "modify" these tables. Support the permissions of each type of record, see \TYPO3\CMS\Core\Authentication\BackendUserAuthentication::check.
- $language : int = null
-
Select specific language only
Return values
array<string|int, mixed> —Array of all records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oidfields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid
fetchPagesWithVersionsInTable()
Gets all pages that have workspace versions in a particular table.
protected
fetchPagesWithVersionsInTable(int $workspaceId, string $tableName) : array<string|int, mixed>
Result: [ 1 => true, 11 => true, 13 => true, 15 => true ],
Parameters
- $workspaceId : int
- $tableName : string
Return values
array<string|int, mixed>filterPermittedElements()
Remove all records which are not permitted for the user
protected
filterPermittedElements(array<string|int, mixed> $recs, string $table) : array<string|int, mixed>
Parameters
- $recs : array<string|int, mixed>
- $table : string
Return values
array<string|int, mixed>getBackendUser()
protected
getBackendUser() : BackendUserAuthentication
Return values
BackendUserAuthenticationgetLanguageService()
protected
getLanguageService() : LanguageService
Return values
LanguageServicegetMovedRecordsFromPages()
Find all moved records at their new position.
protected
getMovedRecordsFromPages(string $table, string $pageList, int $wsid, int $stage) : array<string|int, mixed>
Parameters
- $table : string
- $pageList : string
- $wsid : int
- $stage : int
Return values
array<string|int, mixed>getNewVersionsForPages()
Find all versionized elements which are new (= do not have a live counterpart), so this method does not need to have a JOIN SQL statement.
protected
getNewVersionsForPages(string $table, string $pageList, int $wsid, int $stage, int|null $language) : array<string|int, mixed>
Parameters
- $table : string
- $pageList : string
- $wsid : int
- $stage : int
- $language : int|null
Return values
array<string|int, mixed>getPageChildrenRecursive()
Recursively fetch all children of a given page
protected
getPageChildrenRecursive(int $pid, int $depth, int $begin, string $permsClause) : array<string|int, int>
Parameters
- $pid : int
-
uid of the page
- $depth : int
- $begin : int
- $permsClause : string
Return values
array<string|int, int> —List of child row $uid's
getTreeUids()
Find all page uids recursive starting from a specific page
protected
getTreeUids(int $pageId, int $wsid, int $recursionLevel) : string
Parameters
- $pageId : int
- $wsid : int
- $recursionLevel : int
Return values
string —Comma sep. uid list
isLanguageAccessibleForCurrentUser()
Check current be users language access on given record.
protected
isLanguageAccessibleForCurrentUser(string $table, array<string|int, mixed> $record) : bool
Parameters
- $table : string
-
Name of the table
- $record : array<string|int, mixed>
-
Record row to be checked
Return values
boolisPageAccessibleForCurrentUser()
Checking access to the page the record is on, respecting ignored root level restrictions
protected
isPageAccessibleForCurrentUser(string $table, array<string|int, mixed> $record) : bool
Parameters
- $table : string
-
Name of the table
- $record : array<string|int, mixed>
-
Record row to be checked
Return values
boolselectAllVersionsFromPages()
Find all versionized elements except moved and new records.
protected
selectAllVersionsFromPages(string $table, string $pageList, int $wsid, int $stage[, int $language = null ]) : array<string|int, mixed>
Parameters
- $table : string
- $pageList : string
- $wsid : int
- $stage : int
- $language : int = null