BreakpointManager::getGroups

public BreakpointManager::getGroups()

Gets all the existing breakpoint groups.

Return value

array Array of breakpoint group labels. Keyed by group name.

Overrides BreakpointManagerInterface::getGroups

File

core/modules/breakpoint/src/BreakpointManager.php, line 181

Class

BreakpointManager
Defines a breakpoint plugin manager to deal with breakpoints.

Namespace

Drupal\breakpoint

Code

public function getGroups() {
  // Use a double colon so as to not clash with the cache for each group.
  if ($cache = $this->cacheBackend->get($this->cacheKey . '::groups')) {
    $groups = $cache->data;
  }
  else {
    $groups = array();
    foreach ($this->getDefinitions() as $plugin_definition) {
      if (!isset($groups[$plugin_definition['group']])) {
        $groups[$plugin_definition['group']] = $plugin_definition['group'];
      }
    }
    $this->cacheBackend->set($this->cacheKey . '::groups', $groups, Cache::PERMANENT, array('breakpoints'));
  }
  // Get the labels. This is not cacheable due to translation.
  $group_labels = array();
  foreach ($groups as $group) {
    $group_labels[$group] = $this->getGroupLabel($group);
  }
  asort($group_labels);
  return $group_labels;
}
doc_Drupal
2016-10-29 08:48:54
Comments
Leave a Comment

Please login to continue.