PageInformationFactory

Read onlyYes
FinalYes

Create the PageInformation object. This is typically fired by a middleware. It does all the heavy lifting, page access checks, resolves shortcuts, workspaces, languages and similar.

Possible results:

  • The fully set up PageInformation object is returned.
  • A PageInformationCreationFailedException is thrown that contains an early Response from the ErrorController
  • A StatusException is thrown when ErrorController itself failed
Internal
Tags
todo:

This class also sets / resets the Context language aspect as not directly obvious side effect. This can't be refactored currently due to the dependency of stateful PageRepository to the stateful singleton Context.

Table of Contents

Methods

__construct()  : mixed
create()  : PageInformation
Set up proper PageInformation object later available as 'frontend.page.information' Request attribute.
checkBackendUserAccess()  : void
When a backend user is logged in, it needs at least 'show' permissions.
checkCrossDomainWithDirectId()  : void
When calling a page with a direct id 'https://my.domain/?id=123', this the site object of 'my.domain' is determined from an earlier middleware.
checkRootlineForIncludeSection()  : void
Checks if visibility of the page is blocked upwards in the root line.
getBackendUser()  : FrontendBackendUserAuthentication|null
getRootlineOrThrow()  : array<string|int, mixed>
setContentFromPid()  : PageInformation
Check the value of 'content_from_pid' of the current page record, to see if the current request should actually show content from another page.
setLocalRootLine()  : PageInformation
Calculate "local" rootLine that stops at first root=1 template.
setPageAndRootline()  : PageInformation
Main lifting. Final page and the matching root line are determined and loaded.
setPageLayout()  : PageInformation
Resolve the selected backend layout for the current page and add it to the page information
setSysTemplateRows()  : PageInformation
Determine relevant sys_template rows and set to PageInformation object.
settingLanguage()  : PageInformation
Determine the final Context language aspect, page record based on language settings, existing page overlay and its rootLine.

Methods

__construct()

public __construct(Context $context, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger, RecordAccessVoter $accessVoter, ErrorController $errorController, SysTemplateRepository $sysTemplateRepository, PageLayoutResolver $pageLayoutResolver) : mixed
Parameters
$context : Context
$eventDispatcher : EventDispatcherInterface
$logger : LoggerInterface
$accessVoter : RecordAccessVoter
$errorController : ErrorController
$sysTemplateRepository : SysTemplateRepository
$pageLayoutResolver : PageLayoutResolver

create()

Set up proper PageInformation object later available as 'frontend.page.information' Request attribute.

public create(ServerRequestInterface $request) : PageInformation

At this point, the Context object already contains relevant preview settings, for instance if a backend user is logged in.

As a not obvious side effect, this class also sets the

Parameters
$request : ServerRequestInterface
Internal

Extensions should not call themselves, use events.

Tags
throws
PageInformationCreationFailedException
throws
StatusException
Return values
PageInformation

checkCrossDomainWithDirectId()

When calling a page with a direct id 'https://my.domain/?id=123', this the site object of 'my.domain' is determined from an earlier middleware.

protected checkCrossDomainWithDirectId(ServerRequestInterface $request, PageInformation $pageInformation) : void

If now '123' is not a (sub) page of the 'my.domain' site, we error out since we don't want to directly render content of a different site page within "our" site. Except if '123' is a shortcut, we still allow it, since that will trigger a redirect to the url with the shortcut target domain later.

Parameters
$request : ServerRequestInterface
$pageInformation : PageInformation
Tags
throws
PageInformationCreationFailedException
throws
StatusException

checkRootlineForIncludeSection()

Checks if visibility of the page is blocked upwards in the root line.

protected checkRootlineForIncludeSection(ServerRequestInterface $request, PageInformation $pageInformation) : void

The blocking feature of a page must be turned on by setting the page record field 'extendToSubpages' to 1 for 'hidden', 'starttime', 'endtime' 'fe_group' restrictions to bubble down in rootLine.

Additionally, this method checks for backend user sections in root line and if found, evaluates if a backend user is logged in and has access.

Parameters
$request : ServerRequestInterface
$pageInformation : PageInformation
Tags
throws
PageInformationCreationFailedException
throws
StatusException

getRootlineOrThrow()

protected getRootlineOrThrow(ServerRequestInterface $request, int $pageId, string $mountPoint) : array<string|int, mixed>
Parameters
$request : ServerRequestInterface
$pageId : int
$mountPoint : string
Tags
throws
PageInformationCreationFailedException
throws
StatusException
Return values
array<string|int, mixed>

setContentFromPid()

Check the value of 'content_from_pid' of the current page record, to see if the current request should actually show content from another page.

protected setContentFromPid(ServerRequestInterface $request, PageInformation $pageInformation) : PageInformation

If so, PageInformation->getContentFromPid() is set to the page id of the content page, while PageInformation->getId() is kept as the original page id. If there is no 'content_from_pid', PageInformation->getId() and PageInformation->getContentFromPid() end up carrying the same page ids.

Parameters
$request : ServerRequestInterface
$pageInformation : PageInformation
Tags
throws
PageInformationCreationFailedException
throws
StatusException
Return values
PageInformation

setSysTemplateRows()

Determine relevant sys_template rows and set to PageInformation object.

protected setSysTemplateRows(ServerRequestInterface $request, PageInformation $pageInformation) : PageInformation
Parameters
$request : ServerRequestInterface
$pageInformation : PageInformation
Tags
todo:

Even though all rootline sys_template records are fetched with only one query in below implementation, we could potentially join or sub select sys_template records already when pages rootline is queried. This will save one query. This could be done when we manage to switch PageRepository / RootlineUtility to a CTE.

throws
PageInformationCreationFailedException
throws
StatusException
Return values
PageInformation

settingLanguage()

Determine the final Context language aspect, page record based on language settings, existing page overlay and its rootLine.

protected settingLanguage(ServerRequestInterface $request, PageInformation $pageInformation) : PageInformation

May reset: $pageInformation->pageRecord $pageInformation->pageRepository $pageInformation->rootLine

Parameters
$request : ServerRequestInterface
$pageInformation : PageInformation
Tags
throws
PageInformationCreationFailedException
throws
StatusException
Return values
PageInformation

        
On this page

Search results