‪TYPO3CMS  ‪main
TYPO3\CMS\Workspaces\Middleware\WorkspacePreview Class Reference
Inheritance diagram for TYPO3\CMS\Workspaces\Middleware\WorkspacePreview:

Public Member Functions

 __construct (private readonly Context $context)
 
 process (ServerRequestInterface $request, RequestHandlerInterface $handler)
 
 typoScriptDeterminedListener (AfterTypoScriptDeterminedEvent $event)
 

Private Member Functions

 getLogoutTemplateMessage (UriInterface $currentUrl)
 
int null getWorkspaceIdFromRequest (string $inputCode)
 
PreviewUserAuthentication null initializePreviewUser (int $workspaceUid)
 
 addCookie (string $keyword, NormalizedParams $normalizedParams, ResponseInterface $response)
 
 getPreviewInputCode (ServerRequestInterface $request)
 
mixed getPreviewData (string $keyword)
 
 renderPreviewInfo (UriInterface $currentUrl)
 
 getWorkspaceTitle (int $workspaceId)
 
 removePreviewParameterFromUrl (UriInterface $url, string $newAdminCommand='')
 
 getLanguageService ()
 
 setBackendUserAspect (BackendUserAuthentication $user=null)
 

Private Attributes

const PREVIEW_KEY = 'ADMCMD_prev'
 
bool $previewNotificationEnabled = false
 
string $previewMessage = null
 

Detailed Description

Middleware to

  • ‪evaluate ADMCMD_prev as GET parameter or from a cookie
  • ‪initializes the PreviewUser as $GLOBALS['BE_USER']
  • ‪renders a message about a possible workspace previewing currently

Definition at line 54 of file WorkspacePreview.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::__construct ( private readonly Context  $context)

Definition at line 66 of file WorkspacePreview.php.

Member Function Documentation

◆ addCookie()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::addCookie ( string  $keyword,
NormalizedParams  $normalizedParams,
ResponseInterface  $response 
)
private

Adds a cookie for logging in a preview user into the HTTP response

Definition at line 237 of file WorkspacePreview.php.

References $GLOBALS, TYPO3\CMS\Core\Http\NormalizedParams\getSitePath(), and TYPO3\CMS\Core\Http\NormalizedParams\isHttps().

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ getLanguageService()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getLanguageService ( )
private

◆ getLogoutTemplateMessage()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getLogoutTemplateMessage ( UriInterface  $currentUrl)
private

Renders the logout template when the "logout" button was pressed. Returns a string which can be put into a HttpResponse.

Definition at line 170 of file WorkspacePreview.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getLanguageService(), and TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\removePreviewParameterFromUrl().

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ getPreviewData()

mixed TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getPreviewData ( string  $keyword)
private

Look for keyword configuration record in the database, but check if the keyword has expired already

Returns
‪mixed array of the result set or null

Definition at line 273 of file WorkspacePreview.php.

References $GLOBALS, and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getWorkspaceIdFromRequest().

◆ getPreviewInputCode()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getPreviewInputCode ( ServerRequestInterface  $request)
private

Returns the input code value from the admin command variable If no input code and a cookie is set, load input code from cookie

Definition at line 263 of file WorkspacePreview.php.

References TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\PREVIEW_KEY.

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ getWorkspaceIdFromRequest()

int null TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getWorkspaceIdFromRequest ( string  $inputCode)
private

Looking for an ADMCMD_prev code, looks it up if found and returns configuration data. Background: From the backend a request to the frontend to show a page, possibly with workspace preview can be "recorded" and associated with a keyword. When the frontend is requested with this keyword the associated request parameters are restored from the database AND the backend user is loaded - only for that request. The main point is that a special URL valid for a limited time, e.g. http://localhost/typo3site/index.php?ADMCMD_prev=035d9bf938bd23cb657735f68a8cedbf will open up for a preview that doesn't require login. Thus, it's useful for sending in an email to someone without backend account.

Returns
‪int|null Workspace ID stored in the preview configuration array of a sys_preview record.
Exceptions

Definition at line 204 of file WorkspacePreview.php.

References TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getPreviewData().

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ getWorkspaceTitle()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::getWorkspaceTitle ( int  $workspaceId)
private

Fetches the title of the workspace

Definition at line 344 of file WorkspacePreview.php.

References TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\renderPreviewInfo().

◆ initializePreviewUser()

PreviewUserAuthentication null TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::initializePreviewUser ( int  $workspaceUid)
private

Creates a preview user and sets the workspace ID

Parameters
int$workspaceUid‪the workspace ID to set
Returns
‪PreviewUserAuthentication|null if the set up of the workspace was successful, the user is returned.

Definition at line 225 of file WorkspacePreview.php.

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ process()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::process ( ServerRequestInterface  $request,
RequestHandlerInterface  $handler 
)

◆ removePreviewParameterFromUrl()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::removePreviewParameterFromUrl ( UriInterface  $url,
string  $newAdminCommand = '' 
)
private

Used for generating URLs (e.g. in logout page) without the existing ADMCMD_prev keyword as GET variable

Definition at line 364 of file WorkspacePreview.php.

References TYPO3\CMS\Webhooks\Message\$url, and TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\PREVIEW_KEY.

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getLogoutTemplateMessage(), and TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\renderPreviewInfo().

◆ renderPreviewInfo()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::renderPreviewInfo ( UriInterface  $currentUrl)
private

Renders a message at the bottom of the HTML page, can be modified via config.disablePreviewNotification = 1 (to disable the additional info text) and config.message_preview_workspace = This is not the online version but the version of "%s" workspace (ID: s). via TypoScript.

Definition at line 295 of file WorkspacePreview.php.

References $GLOBALS, TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getLanguageService(), TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\getWorkspaceTitle(), and TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\removePreviewParameterFromUrl().

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ setBackendUserAspect()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::setBackendUserAspect ( BackendUserAuthentication  $user = null)
private

Register or override the backend user as aspect, as well as the workspace information the user object is holding

Definition at line 388 of file WorkspacePreview.php.

Referenced by TYPO3\CMS\Workspaces\Middleware\WorkspacePreview\process().

◆ typoScriptDeterminedListener()

TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::typoScriptDeterminedListener ( AfterTypoScriptDeterminedEvent  $event)

This middleware is run pretty early in the FE chain to initialize correctly. To render the preview information however, it depends on TypoScript 'config', which is not available in the incoming Request, yet. It thus listens on the AfterTypoScriptDeterminedEvent to determine its preview details.

Definition at line 155 of file WorkspacePreview.php.

References TYPO3\CMS\Frontend\Event\AfterTypoScriptDeterminedEvent\getFrontendTypoScript().

Member Data Documentation

◆ $previewMessage

string TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::$previewMessage = null
private

Definition at line 64 of file WorkspacePreview.php.

◆ $previewNotificationEnabled

bool TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::$previewNotificationEnabled = false
private

Definition at line 63 of file WorkspacePreview.php.

◆ PREVIEW_KEY

const TYPO3\CMS\Workspaces\Middleware\WorkspacePreview::PREVIEW_KEY = 'ADMCMD_prev'
private