public function ParagraphsStylePlugin::getStyles in Paragraphs Collection 8
Gets the current styles for each enabled group.
Parameters
\Drupal\paragraphs\ParagraphInterface $paragraph: The paragraph.
Return value
string[] A list of enabled styles, keyed by the group ID.
3 calls to ParagraphsStylePlugin::getStyles()
- ParagraphsStylePlugin::buildBehaviorForm in src/Plugin/ paragraphs/ Behavior/ ParagraphsStylePlugin.php 
- Builds a behavior perspective for each paragraph based on its type.
- ParagraphsStylePlugin::getStyleTemplates in src/Plugin/ paragraphs/ Behavior/ ParagraphsStylePlugin.php 
- Get the template setting of the styles of the Paragraph.
- ParagraphsStylePlugin::view in src/Plugin/ paragraphs/ Behavior/ ParagraphsStylePlugin.php 
- Extends the paragraph render array with behavior.
File
- src/Plugin/ paragraphs/ Behavior/ ParagraphsStylePlugin.php, line 370 
Class
- ParagraphsStylePlugin
- Provides style selection plugin.
Namespace
Drupal\paragraphs_collection\Plugin\paragraphs\BehaviorCode
public function getStyles(ParagraphInterface $paragraph) {
  $defaults = [];
  foreach ($this->configuration['groups'] as $group_id => $group_configuration) {
    $defaults[$group_id] = $group_configuration['default'];
  }
  if ($styles_config = $paragraph
    ->getBehaviorSetting('style', 'styles')) {
    // Ensure that a style is enabled, is enabled and the group is enabled.
    foreach ($styles_config as $group_id => $style) {
      if ($style && $this->yamlStyleDiscovery
        ->getStyle($style) && isset($this->configuration['groups'][$group_id])) {
        $defaults[$group_id] = $style;
      }
    }
  }
  elseif ($style_config = $paragraph
    ->getBehaviorSetting('style', 'style')) {
    // If there is old config, map it to the current one.
    if ($style = $this->yamlStyleDiscovery
      ->getStyle($style_config)) {
      foreach (array_keys($this->configuration['groups']) as $group_id) {
        if (in_array($group_id, $style['groups'])) {
          $defaults[$group_id] = $style_config;
        }
      }
    }
  }
  return $defaults;
}