You are here

function _breakpoint_import_breakpoint_groups in Breakpoints 8

Import breakpoint groups from theme or module.

Parameters

string $group_id: Identifier of the breakpoint group.

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

2 calls to _breakpoint_import_breakpoint_groups()
BreakpointThemeTest::testThemeBreakpointGroupModule in lib/Drupal/breakpoint/Tests/BreakpointThemeTest.php
Test the breakpoints defined by the custom group in the module.
_breakpoint_import_media_queries in ./breakpoint.module
Import media queries from a theme or module and create a default group.

File

./breakpoint.module, line 126
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 $id => $data) {

      // Breakpoints is mandatory, extra check since this is coming from config.
      if (isset($data['breakpoints']) && !empty($data['breakpoints'])) {
        if ($breakpoint_group = BreakpointGroup::ImportBreakpointGroup($source, $source_type, $id, isset($data['label']) ? $data['label'] : drupal_ucfirst($data[$id]), $data['breakpoints'])) {
          $breakpoint_group
            ->save();
        }
      }
    }
  }
}