コード例 #1
0
 /**
  * Gets list of options for language root selection (linking multiple fallback roots on different domains).
  *
  * @param DataContainer $dc
  *
  * @return array
  */
 public function onLanguageRootOptions(DataContainer $dc)
 {
     /** @var PageModel[] $pages */
     $pages = PageModel::findBy(["tl_page.type='root'", "tl_page.fallback='1'", 'tl_page.languageRoot=0', 'tl_page.id!=?'], [$dc->id]);
     if (null === $pages) {
         return [];
     }
     $options = [];
     foreach ($pages as $page) {
         $options[$page->id] = sprintf('%s%s [%s]', $page->title, strlen($page->dns) ? ' (' . $page->dns . ')' : '', $page->language);
     }
     return $options;
 }
コード例 #2
0
 /**
  * @param array $columns
  * @param array $values
  * @param array $options
  *
  * @return \Contao\PageModel[]
  */
 private function findPages(array $columns, array $values, array $options = [])
 {
     /** @var Collection $collection */
     $collection = PageModel::findBy($columns, $values, $options);
     if (!$collection instanceof Collection) {
         return [];
     }
     $models = [];
     foreach ($collection as $model) {
         $models[$model->id] = $model;
     }
     return $models;
 }