You are here

function front_page_get_by_role in Front Page 8

Same name and namespace in other branches
  1. 6.2 front_page.module \front_page_get_by_role()
  2. 7.2 front_page.module \front_page_get_by_role()
  3. 9.1.x front_page.module \front_page_get_by_role()

Function to return the first role enabled in front page, ordered by weight.

File

./front_page.module, line 58
This module allows the site admin to set advanced front page settings.

Code

function front_page_get_by_role($index = 0, $number = 1) {
  $roles = \Drupal::currentUser()
    ->getRoles();
  $result = Database::getConnection()
    ->select('front_page', 'fp')
    ->fields('fp')
    ->condition('rid', $roles, 'IN')
    ->condition('mode', '', '<>')
    ->orderBy('weight', 'ASC')
    ->orderBy('rid', 'DESC')
    ->range($index, $number)
    ->execute()
    ->fetchAssoc();
  return $result;
}