FluidTYPO3\Fluidpages\Service\PageService::getPageTemplateConfiguration PHP Method

getPageTemplateConfiguration() public method

WARNING: do NOT use the output of this feature to overwrite $row - the record returned may or may not be the same record as defined in $id.
public getPageTemplateConfiguration ( integer $pageUid ) : array | null
$pageUid integer
return array | null
    public function getPageTemplateConfiguration($pageUid)
    {
        $pageUid = (int) $pageUid;
        if (1 > $pageUid) {
            return null;
        }
        $page = $this->workspacesAwareRecordService->getSingle('pages', '*', $pageUid);
        // Initialize with possibly-empty values and loop root line
        // to fill values as they are detected.
        $resolvedMainTemplateIdentity = $page['tx_fed_page_controller_action'];
        $resolvedSubTemplateIdentity = $page['tx_fed_page_controller_action_sub'];
        do {
            $containsSubDefinition = false !== strpos($page['tx_fed_page_controller_action_sub'], '->');
            $isCandidate = (int) $page['uid'] !== $pageUid;
            if (true === $containsSubDefinition && true === $isCandidate) {
                $resolvedSubTemplateIdentity = $page['tx_fed_page_controller_action_sub'];
                if (true === empty($resolvedMainTemplateIdentity)) {
                    // Conditions met: current page is not $pageUid, original page did not
                    // contain a "this page" layout, current rootline page has "sub" selection.
                    // Then, set our "this page" value to use the "sub" selection that was detected.
                    $resolvedMainTemplateIdentity = $resolvedSubTemplateIdentity;
                }
                break;
            }
            // Note: 't3ver_oid' is analysed in order to make versioned records inherit the original record's
            // configuration as an emulated first parent page.
            $resolveParentPageUid = (int) (0 > $page['pid'] ? $page['t3ver_oid'] : $page['pid']);
            $page = $this->workspacesAwareRecordService->getSingle('pages', '*', $resolveParentPageUid);
        } while (null !== $page);
        if (true === empty($resolvedMainTemplateIdentity) && true === empty($resolvedSubTemplateIdentity)) {
            // Neither directly configured "this page" nor inherited "sub" contains a valid value;
            // no configuration was detected at all.
            return null;
        }
        return ['tx_fed_page_controller_action' => $resolvedMainTemplateIdentity, 'tx_fed_page_controller_action_sub' => $resolvedSubTemplateIdentity];
    }

Usage Example

Example #1
0
 /**
  * @param array $row
  * @return string
  */
 public function getControllerActionReferenceFromRecord(array $row)
 {
     if (true === empty($row[self::FIELD_ACTION_MAIN])) {
         $row = $this->pageService->getPageTemplateConfiguration($row['uid']);
     }
     return $row[self::FIELD_ACTION_MAIN];
 }
All Usage Examples Of FluidTYPO3\Fluidpages\Service\PageService::getPageTemplateConfiguration