public function StyleDiscovery::getStyleGroups in Paragraphs Collection 8
Gets style groups.
Return value
array Collection of style groups.
Overrides StyleDiscoveryInterface::getStyleGroups
3 calls to StyleDiscovery::getStyleGroups()
- StyleDiscovery::getGroupLabel in src/
StyleDiscovery.php - Gets group label.
- StyleDiscovery::getGroupWidgetLabel in src/
StyleDiscovery.php - Gets group label for a widget context.
- StyleDiscovery::getStyleGroupsLabel in src/
StyleDiscovery.php - Gets style groups label.
File
- src/
StyleDiscovery.php, line 250
Class
- StyleDiscovery
- Provides common helper methods for style discovery. @todo Create documentation for style discovery https://www.drupal.org/node/2837995
Namespace
Drupal\paragraphs_collectionCode
public function getStyleGroups() {
$cache_id = 'paragraphs_collection_style_group';
if ($this->groupCollection !== NULL) {
return $this->groupCollection;
}
else {
if ($cached = $this->cache
->get($cache_id)) {
$this->groupCollection = $cached->data;
}
else {
$yaml_discovery = $this
->getYamlGroupDiscovery();
$this->groupCollection = [];
foreach ($yaml_discovery
->findAll() as $module => $groups) {
foreach ($groups as $group => $definition) {
if (empty($definition['label'])) {
throw new InvalidStyleException('The "label" of "' . $group . '" must be non-empty.');
}
$this->groupCollection[$group] = [
'label' => $this
->t($definition['label']),
'widget_label' => isset($definition['widget_label']) ? $this
->t($definition['widget_label']) : NULL,
];
}
}
$this->cache
->set($cache_id, $this->groupCollection);
}
}
return $this->groupCollection;
}