You are here

function breakpoint_group_reload_from_module in Breakpoints 8

Reload breakpoint groups as they were defined in the module.

Parameters

string $module: The name of the module.

string $group_id: Identifier of the breakpoint group.

Return value

Drupal\breakpoint\BreakpointGroup|false Returns a BreakpointGroup containing the breakpoints defined by the module.

1 call to breakpoint_group_reload_from_module()
BreakpointGroup::revert in lib/Drupal/breakpoint/BreakpointGroup.php
Revert a breakpoint group after it has been overridden.

File

./breakpoint.module, line 236
Manage breakpoints and breakpoint groups for responsive designs.

Code

function breakpoint_group_reload_from_module($module, $group_id) {

  // Clear caches so module info is fresh.
  system_rebuild_module_data();
  module_list_reset();
  $modules = module_list();
  if (isset($modules[$module])) {
    $breakpoint_groups = config($module . '.breakpoint_groups');
    if ($breakpoint_groups) {
      foreach ($breakpoint_groups
        ->get() as $id => $data) {
        if ($id == $group_id) {

          // Breakpoints is mandatory, extra check since this is coming from config.
          if (isset($data['breakpoints']) && !empty($data['breakpoints'])) {
            if ($breakpoint_group = BreakpointGroup::ImportBreakpointGroup($module, Breakpoint::SOURCE_TYPE_MODULE, $id, isset($data['label']) ? $data['label'] : drupal_ucfirst($data[$id]), $data['breakpoints'])) {
              return $breakpoint_group;
            }
          }
        }
      }
    }
  }
  return FALSE;
}