‪TYPO3CMS  ‪main
TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder Class Reference

Public Member Functions

 __construct (EventDispatcherInterface $eventDispatcher, WorkspaceService $workspaceService)
 
string buildUriForPage (int $uid, int $languageId=0)
 
 buildUrisForAllLanguagesOfPage (int $pageId)
 
 buildUriForWorkspaceSplitPreview (int $uid)
 
 buildUriForElement (string $table, int $uid, ?array $liveRecord=null, ?array $versionRecord=null)
 

Protected Member Functions

 createPreviewUriForElement (string $table, int $uid, ?array $liveRecord=null, ?array $versionRecord=null)
 
string compilePreviewKeyword (int $ttl=172800, ?int $workspaceId=null)
 
 getLivePageUid (int $uid)
 
array getAvailableLanguages (int $pageId)
 
 getBackendUser ()
 

Protected Attributes

array $pageCache = array( )
 
WorkspaceService $workspaceService
 
EventDispatcherInterface $eventDispatcher
 
int $previewLinkLifetime
 

Detailed Description

Create links to pages when in a workspace for previewing purposes

Definition at line 48 of file PreviewUriBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::__construct ( EventDispatcherInterface  $eventDispatcher,
WorkspaceService  $workspaceService 
)

Member Function Documentation

◆ buildUriForElement()

TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::buildUriForElement ( string  $table,
int  $uid,
?array  $liveRecord = null,
?array  $versionRecord = null 
)

Generates a view URI for an element.

Parameters
string$table‪Table to be used
int$uid‪Uid of the version(!) record
array$liveRecord‪Optional live record data
array$versionRecord‪Optional version record data

Definition at line 145 of file PreviewUriBuilder.php.

References TYPO3\CMS\Webhooks\Message\$uid, and TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder\createPreviewUriForElement().

◆ buildUriForPage()

string TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::buildUriForPage ( int  $uid,
int  $languageId = 0 
)

Generates a workspace preview link.

Parameters
int$uid‪The ID of the record to be linked
int$languageId‪the language to link to
Returns
‪string the full domain including the protocol http:// or https://, but without the trailing '/'

Definition at line 80 of file PreviewUriBuilder.php.

References TYPO3\CMS\Webhooks\Message\$uid, and TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder\compilePreviewKeyword().

Referenced by TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder\buildUrisForAllLanguagesOfPage().

◆ buildUriForWorkspaceSplitPreview()

TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::buildUriForWorkspaceSplitPreview ( int  $uid)

Generates a workspace split-bar preview link.

Parameters
int$uid‪The ID of the record to be linked
Exceptions

Definition at line 123 of file PreviewUriBuilder.php.

References TYPO3\CMS\Webhooks\Message\$uid, TYPO3\CMS\Backend\Routing\UriBuilder\ABSOLUTE_URL, and TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder\getLivePageUid().

◆ buildUrisForAllLanguagesOfPage()

TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::buildUrisForAllLanguagesOfPage ( int  $pageId)

Generate workspace preview links for all available languages of a page

Definition at line 105 of file PreviewUriBuilder.php.

References TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder\buildUriForPage(), and TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder\getAvailableLanguages().

◆ compilePreviewKeyword()

string TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::compilePreviewKeyword ( int  $ttl = 172800,
?int  $workspaceId = null 
)
protected

Adds an entry to the sys_preview database table and return the preview keyword.

Parameters
int$ttl‪Time-To-Live for keyword
int | null$workspaceId‪Which workspace ID to preview.
Returns
‪string Returns keyword to use in URL for ADMCMD_prev=, a 32 byte MD5 hash keyword for the URL: "?ADMCMD_prev=[keyword]

Definition at line 242 of file PreviewUriBuilder.php.

References $GLOBALS, and TYPO3\CMS\Core\Utility\StringUtility\getUniqueId().

Referenced by TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder\buildUriForPage().

◆ createPreviewUriForElement()

TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::createPreviewUriForElement ( string  $table,
int  $uid,
?array  $liveRecord = null,
?array  $versionRecord = null 
)
protected

◆ getAvailableLanguages()

array TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::getAvailableLanguages ( int  $pageId)
protected

Get the available languages of a certain page, including language=0 if the user has access to it.

Returns
‪array assoc array with the languageId as key and the languageTitle as value

Definition at line 286 of file PreviewUriBuilder.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder\getBackendUser(), and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder\buildUrisForAllLanguagesOfPage().

◆ getBackendUser()

TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::getBackendUser ( )
protected

◆ getLivePageUid()

TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::getLivePageUid ( int  $uid)
protected

Find the Live-Uid for a given page, the results are cached at run-time to avoid too many database-queries

Exceptions

Definition at line 268 of file PreviewUriBuilder.php.

References TYPO3\CMS\Webhooks\Message\$uid.

Referenced by TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder\buildUriForWorkspaceSplitPreview().

Member Data Documentation

◆ $eventDispatcher

EventDispatcherInterface TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::$eventDispatcher
protected

◆ $pageCache

array TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::$pageCache = array( )
protected

Definition at line 52 of file PreviewUriBuilder.php.

◆ $previewLinkLifetime

int TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::$previewLinkLifetime
protected

Definition at line 64 of file PreviewUriBuilder.php.

◆ $workspaceService

WorkspaceService TYPO3\CMS\Workspaces\Preview\PreviewUriBuilder::$workspaceService
protected