‪TYPO3CMS  10.4
TYPO3\CMS\Workspaces\Service\WorkspaceService Class Reference
Inheritance diagram for TYPO3\CMS\Workspaces\Service\WorkspaceService:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

array getAvailableWorkspaces ()
 
int getCurrentWorkspace ()
 
int getPreviewLinkLifetime ()
 
array getCmdArrayForPublishWS ($wsid, $doSwap, $pageId=0, $language=null)
 
array getCmdArrayForFlushWS ($wsid, $flush=true, $pageId=0, $language=null)
 
array selectVersionsInWorkspace ($wsid, $filter=0, $stage=-99, $pageId=-1, $recursionLevel=0, $selectionType='tables_select', $language=null)
 
bool hasPageRecordVersions ($workspaceId, $pageId)
 
array getPagesWithVersionsInTable ($workspaceId)
 

Static Public Member Functions

static string getWorkspaceTitle ($wsId)
 
static bool isNewPage ($id, $language=0)
 

Public Attributes

const TABLE_WORKSPACE = 'sys_workspace'
 
const LIVE_WORKSPACE_ID = 0
 

Protected Member Functions

array selectAllVersionsFromPages ($table, $pageList, $wsid, $filter, $stage, $language=null)
 
array getMoveToPlaceHolderFromPages ($table, $pageList, $wsid, $filter, $stage)
 
string getTreeUids ($pageId, $wsid, $recursionLevel)
 
array filterPermittedElements ($recs, $table)
 
bool isPageAccessibleForCurrentUser ($table, array $record)
 
bool isLanguageAccessibleForCurrentUser ($table, array $record)
 
array fetchPagesWithVersionsInTable ($workspaceId, $tableName)
 
QueryBuilder createQueryBuilderForTable (string $tableName)
 

Static Protected Member Functions

static LanguageService null getLanguageService ()
 

Protected Attributes

array $versionsOnPageCache = array( )
 
array $pagesWithVersionsInTable = array( )
 

Detailed Description

Workspace service

Definition at line 35 of file WorkspaceService.php.

Member Function Documentation

◆ createQueryBuilderForTable()

◆ fetchPagesWithVersionsInTable()

◆ filterPermittedElements()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::filterPermittedElements (   $recs,
  $table 
)
protected

Remove all records which are not permitted for the user

Parameters
array$recs
string$table
Returns
‪array

Definition at line 653 of file WorkspaceService.php.

References TYPO3\CMS\Workspaces\Service\WorkspaceService\isLanguageAccessibleForCurrentUser(), and TYPO3\CMS\Workspaces\Service\WorkspaceService\isPageAccessibleForCurrentUser().

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\selectVersionsInWorkspace().

◆ getAvailableWorkspaces()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::getAvailableWorkspaces ( )

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

Returns
‪array array of workspaces available to the current user

Definition at line 54 of file WorkspaceService.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Service\WorkspaceService\getWorkspaceTitle(), and TYPO3\CMS\Workspaces\Service\WorkspaceService\LIVE_WORKSPACE_ID.

◆ getCmdArrayForFlushWS()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::getCmdArrayForFlushWS (   $wsid,
  $flush = true,
  $pageId = 0,
  $language = null 
)

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

Parameters
int$wsid‪Real workspace ID, cannot be ONLINE (zero).
bool$flush‪Run Flush (TRUE) or ClearWSID (FALSE) command
int$pageId‪The page id
int$language‪Select specific language only
Returns
‪array Command array for DataHandler

Definition at line 184 of file WorkspaceService.php.

References TYPO3\CMS\Workspaces\Service\WorkspaceService\selectVersionsInWorkspace().

◆ getCmdArrayForPublishWS()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::getCmdArrayForPublishWS (   $wsid,
  $doSwap,
  $pageId = 0,
  $language = null 
)

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

Parameters
int$wsid‪Real workspace ID, cannot be ONLINE (zero).
bool$doSwap‪If set, then the currently online versions are swapped into the workspace in exchange for the offline versions. Otherwise the workspace is emptied.
int$pageId‪The page id
int$language‪Select specific language only
Returns
‪array Command array for DataHandler

Definition at line 149 of file WorkspaceService.php.

References TYPO3\CMS\Backend\Utility\BackendUtility\getRecord(), TYPO3\CMS\Workspaces\Service\WorkspaceService\selectVersionsInWorkspace(), and TYPO3\CMS\Workspaces\Service\StagesService\STAGE_PUBLISH_ID.

◆ getCurrentWorkspace()

int TYPO3\CMS\Workspaces\Service\WorkspaceService::getCurrentWorkspace ( )

Gets the current workspace ID.

Returns
‪int The current workspace ID

Definition at line 85 of file WorkspaceService.php.

References $GLOBALS.

◆ getLanguageService()

static LanguageService null TYPO3\CMS\Workspaces\Service\WorkspaceService::getLanguageService ( )
staticprotected
Returns
‪LanguageService|null

Definition at line 953 of file WorkspaceService.php.

References $GLOBALS.

◆ getMoveToPlaceHolderFromPages()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::getMoveToPlaceHolderFromPages (   $table,
  $pageList,
  $wsid,
  $filter,
  $stage 
)
protected

◆ getPagesWithVersionsInTable()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::getPagesWithVersionsInTable (   $workspaceId)

Gets all pages that have workspace versions per table.

Result: [ 'sys_template' => [], 'tt_content' => [ 1 => true, 11 => true, 13 => true, 15 => true ], 'tx_something => [ 15 => true, 11 => true, 21 => true ], ]

Parameters
int$workspaceId
Returns
‪array

Definition at line 821 of file WorkspaceService.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Service\WorkspaceService\fetchPagesWithVersionsInTable(), and TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled().

◆ getPreviewLinkLifetime()

int TYPO3\CMS\Workspaces\Service\WorkspaceService::getPreviewLinkLifetime ( )

easy function to just return the number of hours.

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.

Returns
‪int The hours as a number

Definition at line 100 of file WorkspaceService.php.

References $GLOBALS, and TYPO3\CMS\Backend\Utility\BackendUtility\getRecord().

◆ getTreeUids()

string TYPO3\CMS\Workspaces\Service\WorkspaceService::getTreeUids (   $pageId,
  $wsid,
  $recursionLevel 
)
protected

Find all page uids recursive starting from a specific page

Parameters
int$pageId
int$wsid
int$recursionLevel
Returns
‪string Comma sep. uid list

Definition at line 541 of file WorkspaceService.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\GeneralUtility\intExplode(), TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled(), and TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW.

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\selectVersionsInWorkspace().

◆ getWorkspaceTitle()

◆ hasPageRecordVersions()

bool TYPO3\CMS\Workspaces\Service\WorkspaceService::hasPageRecordVersions (   $workspaceId,
  $pageId 
)

◆ isLanguageAccessibleForCurrentUser()

bool TYPO3\CMS\Workspaces\Service\WorkspaceService::isLanguageAccessibleForCurrentUser (   $table,
array  $record 
)
protected

Check current be users language access on given record.

Parameters
string$table‪Name of the table
array$record‪Record row to be checked
Returns
‪bool

Definition at line 695 of file WorkspaceService.php.

References $GLOBALS, and TYPO3\CMS\Backend\Utility\BackendUtility\isTableLocalizable().

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\filterPermittedElements().

◆ isNewPage()

static bool TYPO3\CMS\Workspaces\Service\WorkspaceService::isNewPage (   $id,
  $language = 0 
)
static

Determine whether a specific page is new and not yet available in the LIVE workspace

Parameters
int$id‪Primary key of the page to check
int$language‪Language for which to check the page
Returns
‪bool

Definition at line 712 of file WorkspaceService.php.

References $GLOBALS, TYPO3\CMS\Core\Type\Enumeration\cast(), TYPO3\CMS\Backend\Utility\BackendUtility\getRecord(), and TYPO3\CMS\Core\Versioning\VersionState\NEW_PLACEHOLDER.

Referenced by TYPO3\CMS\Workspaces\Controller\PreviewController\handleRequest().

◆ isPageAccessibleForCurrentUser()

bool TYPO3\CMS\Workspaces\Service\WorkspaceService::isPageAccessibleForCurrentUser (   $table,
array  $record 
)
protected

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

Parameters
string$table‪Name of the table
array$record‪Record row to be checked
Returns
‪bool

Definition at line 673 of file WorkspaceService.php.

References $GLOBALS, TYPO3\CMS\Backend\Utility\BackendUtility\getRecord(), and TYPO3\CMS\Backend\Utility\BackendUtility\isRootLevelRestrictionIgnored().

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\filterPermittedElements().

◆ selectAllVersionsFromPages()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::selectAllVersionsFromPages (   $table,
  $pageList,
  $wsid,
  $filter,
  $stage,
  $language = null 
)
protected

◆ selectVersionsInWorkspace()

array TYPO3\CMS\Workspaces\Service\WorkspaceService::selectVersionsInWorkspace (   $wsid,
  $filter = 0,
  $stage = -99,
  $pageId = -1,
  $recursionLevel = 0,
  $selectionType = 'tables_select',
  $language = null 
)

Select all records from workspace pending for publishing Used from backend to display workspace overview User for auto-publishing for selecting versions for publication

Parameters
int$wsid‪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
int$filter‪Lifecycle filter: 1 = select all drafts (never-published), 2 = select all published one or more times (archive/multiple), anything else selects all.
int$stage‪Stage filter: -99 means no filtering, otherwise it will be used to select only elements with that stage. For publishing, that would be "10
int$pageId‪Page id: Live page for which to find versions in workspace!
int$recursionLevel‪Recursion Level - select versions recursive - parameter is only relevant if $pageId != -1
string$selectionType‪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.
int$language‪Select specific language only
Returns
‪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

Definition at line 218 of file WorkspaceService.php.

References $GLOBALS, $output, TYPO3\CMS\Workspaces\Service\WorkspaceService\filterPermittedElements(), TYPO3\CMS\Workspaces\Service\WorkspaceService\getMoveToPlaceHolderFromPages(), TYPO3\CMS\Workspaces\Service\WorkspaceService\getTreeUids(), TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled(), and TYPO3\CMS\Workspaces\Service\WorkspaceService\selectAllVersionsFromPages().

Referenced by TYPO3\CMS\Workspaces\Service\WorkspaceService\getCmdArrayForFlushWS(), and TYPO3\CMS\Workspaces\Service\WorkspaceService\getCmdArrayForPublishWS().

Member Data Documentation

◆ $pagesWithVersionsInTable

array TYPO3\CMS\Workspaces\Service\WorkspaceService::$pagesWithVersionsInTable = array( )
protected

◆ $versionsOnPageCache

array TYPO3\CMS\Workspaces\Service\WorkspaceService::$versionsOnPageCache = array( )
protected

◆ LIVE_WORKSPACE_ID

◆ TABLE_WORKSPACE

const TYPO3\CMS\Workspaces\Service\WorkspaceService::TABLE_WORKSPACE = 'sys_workspace'