You are here

function breakpoints_breakpoint_save in Breakpoints 7

Save a single breakpoint.

11 calls to breakpoints_breakpoint_save()
BreakpointGroupAdminTestCase::testBreakpointGroupAdmin in ./breakpoints.test
Test breakpoint administration functionality
BreakpointGroupCRUDTestCase::testBreakpointGroupCRUD in ./breakpoints.test
Test CRUD operations for breakpoint groups.
BreakpointsCRUDTestCase::testBreakpointsCRUD in ./breakpoints.test
Test CRUD operations for breakpoints.
breakpoints_admin_breakpoints_submit in ./breakpoints.admin.inc
Admin form submit.
breakpoints_admin_breakpoint_group_import_form_submit in ./breakpoints.admin.inc
Import breakpoint group.

... See full list

File

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

Code

function breakpoints_breakpoint_save(&$breakpoint) {
  ctools_include('export');
  if (!isset($breakpoint->machine_name) || empty($breakpoint->machine_name)) {
    $breakpoint->machine_name = breakpoints_breakpoint_config_name($breakpoint);
  }
  $update = isset($breakpoint->id) && is_numeric($breakpoint->id) ? array(
    'id',
  ) : array();

  // Remove unused multipliers.
  $breakpoint->multipliers = array_filter($breakpoint->multipliers);
  if (is_null($breakpoint->multipliers)) {
    $breakpoint->multipliers = array();
  }

  // Add the '1x' multiplier.
  $breakpoint->multipliers = array_merge($breakpoint->multipliers, array(
    '1x' => '1x',
  ));
  $result = drupal_write_record('breakpoints', $breakpoint, $update);
  breakpoints_breakpoint_reset();
  return $result;
}