WorkspaceService

readonly class \TYPO3\CMS\Workspaces\Service\WorkspaceService

Tags

todo:

This is public:true only because testing-framework uses GU::makeInstance() on it. Get rid of this.

Attributes

#[Autoconfigure]
$public: true

Table of Contents

Constants

LIVE_WORKSPACE_ID  : mixed = 0
PUBLISH_ACCESS_HIDE_ENTIRE_WORKSPACE_ACTION_DROPDOWN  : mixed = 4
PUBLISH_ACCESS_ONLY_IN_PUBLISH_STAGE  : mixed = 1
PUBLISH_ACCESS_ONLY_WORKSPACE_OWNERS  : mixed = 2

Methods

getAvailableWorkspaces()  : array
Retrieves the available workspaces from the database and checks whether they're available to the current BE user
getCmdArrayForFlushWS()  : array
Building DataHandler CMD-array for releasing all versions in a workspace.
getCmdArrayForPublishWS()  : array
Building DataHandler CMD-array for publishing all versions in a workspace.
getCurrentWorkspace()  : int
Gets the current workspace ID.
getPreviewLinkLifetime()  : int
easy function to just return the number of hours.
getWorkspaceTitle()  : string
Find the title for the requested workspace.
isNewPage()  : bool
Determine whether a specific page is new and not yet available in the LIVE workspace
selectVersionsInWorkspace()  : array
Select all records from workspace pending for publishing Used from backend to display workspace overview User for auto-publishing for selecting versions for publication
filterPermittedElements()  : array
Remove all records which are not permitted for the user
getBackendUser()  : BackendUserAuthentication
getLanguageService()  : LanguageService
getMovedRecordsFromPages()  : array
Find all moved records at their new position.
getNewVersionsForPages()  : array
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()  : int[]
Recursively fetch all children of a given page
getTreeUids()  : string
Find all page uids recursive starting from a specific page
isFileAccessibleForCurrentUser()  : bool
Check if the current backend user has access to the file record.
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
Find all versionized elements except moved and new records.

Constants

LIVE_WORKSPACE_ID

public mixed LIVE_WORKSPACE_ID = 0

PUBLISH_ACCESS_HIDE_ENTIRE_WORKSPACE_ACTION_DROPDOWN

public mixed PUBLISH_ACCESS_HIDE_ENTIRE_WORKSPACE_ACTION_DROPDOWN = 4

PUBLISH_ACCESS_ONLY_IN_PUBLISH_STAGE

public mixed PUBLISH_ACCESS_ONLY_IN_PUBLISH_STAGE = 1

PUBLISH_ACCESS_ONLY_WORKSPACE_OWNERS

public mixed PUBLISH_ACCESS_ONLY_WORKSPACE_OWNERS = 2

Methods

getAvailableWorkspaces()

Retrieves the available workspaces from the database and checks whether they're available to the current BE user

public getAvailableWorkspaces() : array

Return values

array —

array of workspaces available to the current user

getCmdArrayForFlushWS()

Building DataHandler CMD-array for releasing all versions in a workspace.

public getCmdArrayForFlushWS(int $wsid[, int|null $language = null ]) : array

Parameters

$wsid : int

Real workspace ID, cannot be ONLINE (zero).

$language : int|null = null

Select specific language only

Return values

array —

Command array for DataHandler

getCmdArrayForPublishWS()

Building DataHandler CMD-array for publishing all versions in a workspace.

public getCmdArrayForPublishWS(int $wsid[, bool $_ = false ][, int|null $language = null ]) : array

Parameters

$wsid : int

Real workspace ID, cannot be ONLINE (zero).

$_ : bool = false

Dummy parameter, only there because testing framework is calling it with 2 parameters

$language : int|null = null

Select specific language only

Return values

array —

Command array for DataHandler

getCurrentWorkspace()

Gets the current workspace ID.

public getCurrentWorkspace() : int

Return values

int

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

Return values

string

isNewPage()

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

bool

selectVersionsInWorkspace()

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

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 —

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

filterPermittedElements()

Remove all records which are not permitted for the user

protected filterPermittedElements(array $recs, string $table) : array

Parameters

$recs : array
$table : string

Return values

array

getMovedRecordsFromPages()

Find all moved records at their new position.

protected getMovedRecordsFromPages(string $table, string $pageList, int $wsid, int $stage) : array

Parameters

$table : string
$pageList : string
$wsid : int
$stage : int

Return values

array

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

Parameters

$table : string
$pageList : string
$wsid : int
$stage : int
$language : int|null

Return values

array

getPageChildrenRecursive()

Recursively fetch all children of a given page

protected getPageChildrenRecursive(int $pid, int $depth, int $begin, string $permsClause) : int[]

Parameters

$pid : int

uid of the page

$depth : int
$begin : int
$permsClause : string

Return values

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

isFileAccessibleForCurrentUser()

Check if the current backend user has access to the file record.

protected isFileAccessibleForCurrentUser(string $table, array $record) : bool

Parameters

$table : string
$record : array

Return values

bool

isLanguageAccessibleForCurrentUser()

Check current be users language access on given record.

protected isLanguageAccessibleForCurrentUser(string $table, array $record) : bool

Parameters

$table : string

Name of the table

$record : array

Record row to be checked

Return values

bool

isPageAccessibleForCurrentUser()

Checking access to the page the record is on, respecting ignored root level restrictions

protected isPageAccessibleForCurrentUser(string $table, array $record) : bool

Parameters

$table : string

Name of the table

$record : array

Record row to be checked

Return values

bool

selectAllVersionsFromPages()

Find all versionized elements except moved and new records.

protected selectAllVersionsFromPages(string $table, string $pageList, int $wsid, int $stage[, int|null $language = null ]) : array

Parameters

$table : string
$pageList : string
$wsid : int
$stage : int
$language : int|null = null

Return values

array
On this page