You are here

public function BreakpointManager::getBreakpointsByGroup in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/breakpoint/src/BreakpointManager.php \Drupal\breakpoint\BreakpointManager::getBreakpointsByGroup()

Gets breakpoints for the specified group.

Parameters

string $group: The breakpoint group to retrieve.

Return value

\Drupal\breakpoint\BreakpointInterface[] Array of breakpoint plugins keyed by machine name.

Overrides BreakpointManagerInterface::getBreakpointsByGroup

1 call to BreakpointManager::getBreakpointsByGroup()
BreakpointManager::getGroupProviders in core/modules/breakpoint/src/BreakpointManager.php
Gets all the providers for the specified breakpoint group.

File

core/modules/breakpoint/src/BreakpointManager.php, line 155
Contains \Drupal\breakpoint\BreakpointManager.

Class

BreakpointManager
Defines a breakpoint plugin manager to deal with breakpoints.

Namespace

Drupal\breakpoint

Code

public function getBreakpointsByGroup($group) {
  if (!isset($this->breakpointsByGroup[$group])) {
    if ($cache = $this->cacheBackend
      ->get($this->cacheKey . ':' . $group)) {
      $this->breakpointsByGroup[$group] = $cache->data;
    }
    else {
      $breakpoints = array();
      foreach ($this
        ->getDefinitions() as $plugin_id => $plugin_definition) {
        if ($plugin_definition['group'] == $group) {
          $breakpoints[$plugin_id] = $plugin_definition;
        }
      }
      uasort($breakpoints, array(
        'Drupal\\Component\\Utility\\SortArray',
        'sortByWeightElement',
      ));
      $this->cacheBackend
        ->set($this->cacheKey . ':' . $group, $breakpoints, Cache::PERMANENT, array(
        'breakpoints',
      ));
      $this->breakpointsByGroup[$group] = $breakpoints;
    }
  }
  $instances = array();
  foreach ($this->breakpointsByGroup[$group] as $plugin_id => $definition) {
    if (!isset($this->instances[$plugin_id])) {
      $this->instances[$plugin_id] = $this
        ->createInstance($plugin_id);
    }
    $instances[$plugin_id] = $this->instances[$plugin_id];
  }
  return $instances;
}