Contao\PageModel::findPublishedRootPages PHP Метод

findPublishedRootPages() публичный статический Метод

Finds the published root pages
public static findPublishedRootPages ( array $arrOptions = [] ) : Collection | PageModel[] | PageModel | null
$arrOptions array An optional options array
Результат Contao\Model\Collection | PageModel[] | PageModel | null A collection of models or null if there are no parent pages
    public static function findPublishedRootPages(array $arrOptions = array())
    {
        $t = static::$strTable;
        $arrColumns = array("{$t}.type=?");
        if (isset($arrOptions['ignoreFePreview']) || !BE_USER_LOGGED_IN) {
            $time = \Date::floorToMinute();
            $arrColumns[] = "({$t}.start='' OR {$t}.start<='{$time}') AND ({$t}.stop='' OR {$t}.stop>'" . ($time + 60) . "') AND {$t}.published='1'";
        }
        return static::findBy($arrColumns, 'root', $arrOptions);
    }

Usage 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)));
 }