Contao\PageModel::findWithDetails PHP Method

findWithDetails() public static method

Find a page by its ID and return it with the inherited details
public static findWithDetails ( integer $intId ) : PageModel | null
$intId integer The page's ID
return PageModel | null The model or null if there is no matching page
    public static function findWithDetails($intId)
    {
        $objPage = static::findByPk($intId);
        if ($objPage === null) {
            return null;
        }
        return $objPage->loadDetails();
    }

Usage Example

 private function validateLanguageMainForPage($pageId)
 {
     $page = PageModel::findWithDetails($pageId);
     // Moving a root page does not affect language assignments
     if (null === $page || !$page->languageMain || 'root' === $page->type) {
         return;
     }
     $duplicates = PageModel::countBy(['id IN (' . implode(',', Database::getInstance()->getChildRecords($page->rootId, 'tl_page')) . ')', 'languageMain=?', 'id!=?'], [$page->languageMain, $page->id]);
     // Reset languageMain if another page in the new page tree has the same languageMain
     if ($duplicates > 0) {
         $this->resetPageAndChildren($page->id);
         return;
     }
     $pageFinder = new PageFinder();
     $masterRoot = $pageFinder->findMasterRootForPage($page);
     // Reset languageMain if current tree has no master or if it's the master tree
     if (null === $masterRoot || $masterRoot->id === $page->rootId) {
         $this->resetPageAndChildren($page->id);
         return;
     }
     // Reset languageMain if the current value is not a valid ID of the master tree
     if (!in_array($page->id, Database::getInstance()->getChildRecords($masterRoot->id, 'tl_page'), false)) {
         $this->resetPageAndChildren($page->id);
     }
 }
All Usage Examples Of Contao\PageModel::findWithDetails