function _breakpoint_import_breakpoint_groups

Import breakpoint groups from theme or module.

Parameters

string $source: The theme or module name

string $source_type: Either Breakpoint::SOURCE_TYPE_THEME or Breakpoint::SOURCE_TYPE_MODULE.

3 calls to _breakpoint_import_breakpoint_groups()

File

drupal/core/modules/breakpoint/breakpoint.module, line 158
Manage breakpoints and breakpoint groups for responsive designs.

Code

function _breakpoint_import_breakpoint_groups($source, $source_type) {
  $breakpoint_groups = config($source . '.breakpoint_groups');
  if ($breakpoint_groups) {
    foreach ($breakpoint_groups
      ->get() as $group_name => $data) {

      // Breakpoints is mandatory, extra check since this is coming from config.
      if (isset($data['breakpoints']) && !empty($data['breakpoints'])) {

        // Create a new breakpoint group if it doesn't exist.
        $breakpoint_group = _breakpoint_group_create_or_load($group_name, isset($data['label']) ? $data['label'] : $group_name, $source, $source_type);

        // Add the breakpoints.
        $breakpoint_group
          ->addBreakpoints($data['breakpoints']);
        $breakpoint_group
          ->save();
      }
      else {
        throw new \Exception('Illegal config file detected.');
      }
    }
  }
}