protected function calculateClosestPageIdWithActiveTemplate($startPageId)
    {
        $rootLine = $this->pageRepository->getRootLine($startPageId);
        // when no rootline is present the startpage it's self is the closest page
        if (!is_array($rootLine)) {
            return $startPageId;
        }

        $closestPageIdWithTemplate = $this->systemTemplateRepository->findOneClosestPageIdWithActiveTemplateByRootLine($rootLine);
        if ($closestPageIdWithTemplate === 0) {
            return $startPageId;
        }

        return (int)$closestPageIdWithTemplate;
    }
protected function calculateClosestPageIdWithActiveTemplate($startPageId)
    {
        $rootLine = $this->pageRepository->getRootLine($startPageId);
        // when no rootline is present the startpage it's self is the closest page
        if (!is_array($rootLine)) {
            return $startPageId;
        }

        $closestPageIdWithTemplate = $this->systemTemplateRepository->findOneClosestPageIdWithActiveTemplateByRootLine($rootLine);
        if ($closestPageIdWithTemplate === 0) {
            return $startPageId;
        }

        return (int)$closestPageIdWithTemplate;
    }
protected function calculateClosestPageIdWithActiveTemplate ( $ startPageId ) { $ rootLine = $ this -> pageRepository -> getRootLine ( $ startPageId ) ; // when no rootline is present the startpage it's self is the closest page if ( ! is_array ( $ rootLine ) ) { return $ startPageId ; } $ closestPageIdWithTemplate = $ this -> systemTemplateRepository -> findOneClosestPageIdWithActiveTemplateByRootLine ( $ rootLine ) ; if ( $ closestPageIdWithTemplate === 0 ) { return $ startPageId ; } return ( int ) $ closestPageIdWithTemplate ; }
This method fetches the rootLine and calculates the id of the closest template in the rootLine.

@param integer $startPageId
@return int
This method fetches the rootLine and calculates the id of the closest template in the rootLine .