You are here

function responsive_menu_get_breakpoints in Responsive and off-canvas menu 4.0.x

Same name and namespace in other branches
  1. 8.3 responsive_menu.module \responsive_menu_get_breakpoints()
  2. 8.2 responsive_menu.module \responsive_menu_get_breakpoints()
  3. 4.4.x responsive_menu.module \responsive_menu_get_breakpoints()
  4. 4.1.x responsive_menu.module \responsive_menu_get_breakpoints()
  5. 4.3.x responsive_menu.module \responsive_menu_get_breakpoints()

Helper function to gather breakpoint queries.

Return value

array An array of breakpoints with the breakpoint label as the key and breakpoint string as the value.

2 calls to responsive_menu_get_breakpoints()
SettingsForm::buildForm in src/Form/SettingsForm.php
Form constructor.
SettingsForm::submitForm in src/Form/SettingsForm.php
Form submission handler.

File

./responsive_menu.module, line 321
Contains procedural code.

Code

function responsive_menu_get_breakpoints() {
  $queries = [];
  $theme_settings = \Drupal::config('system.theme')
    ->get();
  $default_theme = $theme_settings['default'];
  $breakpoint_groups = \Drupal::service('breakpoint.manager')
    ->getGroups();
  foreach ($breakpoint_groups as $key => $value) {
    if (strpos($key, $default_theme) !== 0) {
      continue;
    }
    $breakpoints = \Drupal::service('breakpoint.manager')
      ->getBreakpointsByGroup($key);

    // Iterate over the breakpoints in the group and store them.
    foreach ($breakpoints as $breakpoint) {
      $label = $breakpoint
        ->getLabel()
        ->render();
      $mediaQuery = $breakpoint
        ->getMediaQuery();
      if ($mediaQuery) {
        $queries[$label] = $mediaQuery;
      }
    }
  }
  return $queries;
}