findPublishedRootPages() public static method

Finds the published root pages
public static findPublishedRootPages ( array $arrOptions = [] ) : Collection | PageModel[] | PageModel | null
$arrOptions array An optional options array
return Contao\Model\Collection | PageModel[] | PageModel | null A collection of models or null if there are no parent pages
Example #1
0
 /**
  * Generates the cache mapper array.
  *
  * @param string $cacheDir The cache directory
  */
 private function generateCacheMapper($cacheDir)
 {
     $mapper = [];
     $pages = PageModel::findPublishedRootPages();
     if (null === $pages) {
         return;
     }
     while ($pages->next()) {
         $base = $pages->dns ?: '*';
         if ($pages->fallback) {
             $mapper[$base . '/empty.fallback'] = $base . '/empty.' . $pages->language;
         }
         $mapper[$base . '/empty.' . $pages->language] = $base . '/empty.' . $pages->language;
     }
     $this->filesystem->dumpFile($cacheDir . '/contao/config/mapping.php', sprintf("<?php\n\nreturn %s;\n", var_export($mapper, true)));
 }