You are here

public function Breakpoint::save in Breakpoints 8

Overrides Drupal\config\ConfigEntityBase::save().

Overrides ConfigEntityBase::save

4 calls to Breakpoint::save()
Breakpoint::disable in lib/Drupal/breakpoint/Breakpoint.php
Shortcut function to disable a breakpoint and save it.
Breakpoint::enable in lib/Drupal/breakpoint/Breakpoint.php
Shortcut function to enable a breakpoint and save it.
Breakpoint::override in lib/Drupal/breakpoint/Breakpoint.php
Override a breakpoint and save it.
Breakpoint::revert in lib/Drupal/breakpoint/Breakpoint.php
Revert a breakpoint and save it.

File

lib/Drupal/breakpoint/Breakpoint.php, line 139
Definition of Drupal\breakpoint\Breakpoint.

Class

Breakpoint
Defines the Breakpoint entity.

Namespace

Drupal\breakpoint

Code

public function save() {
  if (empty($this->id)) {
    $this->id = $this
      ->getConfigName();
  }
  if (empty($this->label)) {
    $this->label = drupal_ucfirst($this->name);
  }

  // Check if everything is valid.
  if (!$this
    ->isValid()) {
    throw new InvalidBreakpointException('Invalid data detected.');
  }

  // Remove ununsed multipliers.
  $this->multipliers = array_filter($this->multipliers);

  // Always add '1x' multiplier.
  if (!array_key_exists('1x', $this->multipliers)) {
    $this->multipliers = array(
      '1x' => '1x',
    ) + $this->multipliers;
  }
  return parent::save();
}