You are here

function breakpoints_breakpoints_group_override in Breakpoints 7

Override the breakpoints of a group.

1 call to breakpoints_breakpoints_group_override()
breakpoints_admin_breakpoints_submit_override in ./breakpoints.admin.inc
Admin form submit - Override theme breakpoints.

File

./breakpoints.module, line 851
Breakpoints @todo: provide button to reload breakpoints from theme

Code

function breakpoints_breakpoints_group_override($group) {
  foreach ($group->breakpoints as $key => $breakpoint) {
    $breakpoint = breakpoints_breakpoint_load_by_fullkey($breakpoint);
    $old_breakpoint = clone $breakpoint;
    if ($breakpoint->source_type == BREAKPOINTS_SOURCE_TYPE_THEME && $breakpoint->source == $group->machine_name) {
      unset($breakpoint->id);
      $breakpoint->machine_name = 'custom.' . $breakpoint->source . '.' . str_replace('-', '_', drupal_clean_css_identifier($breakpoint->name));
      $breakpoint->source_type = BREAKPOINTS_SOURCE_TYPE_CUSTOM;

      // make sure it doesn't already exists.
      if (breakpoints_breakpoint_load_by_fullkey($breakpoint->machine_name) === FALSE) {
        breakpoints_breakpoint_save($breakpoint);
      }

      // Add to the group and delete old breakpoint.
      $group->breakpoints[$key] = $breakpoint->machine_name;
      breakpoints_breakpoint_delete($old_breakpoint, $group->machine_name);
    }
  }
  $group->overridden = 1;
  breakpoints_breakpoint_group_save($group);
}