function _breakpoint_group_create_or_load

Helper function to easily create/load a breakpoint group.

Parameters

string $name: Machine readable name of the breakpoint group.

string $label: Human readable name of the breakpoint group.

string $source: Machine readable name of the defining theme or module.

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

Return value

Drupal\breakpoint\Plugin\Core\Entity\BreakpointGroup

See also

_breakpoint_import_media_queries()

_breakpoint_import_breakpoint_groups()

2 calls to _breakpoint_group_create_or_load()
_breakpoint_import_breakpoint_groups in drupal/core/modules/breakpoint/breakpoint.module
Import breakpoint groups from theme or module.
_breakpoint_import_media_queries in drupal/core/modules/breakpoint/breakpoint.module
Import media queries from a theme or module and create a default group.

File

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

Code

function _breakpoint_group_create_or_load($name, $label, $source, $source_type) {

  // Try loading the breakpoint group.
  $breakpoint_group = entity_load('breakpoint_group', $source_type . '.' . $source . '.' . $name);

  // Create a new breakpoint group if it doesn't exist.
  if (!$breakpoint_group) {

    // Build a new breakpoint group.
    $breakpoint_group = entity_create('breakpoint_group', array(
      'name' => $name,
      'label' => $label,
      'source' => $source,
      'sourceType' => $source_type,
    ));
  }
  return $breakpoint_group;
}