You are here

public function ParagraphsStylePlugin::settingsSummary in Paragraphs Collection 8

Returns a short summary for the current behavior settings.

Parameters

\Drupal\paragraphs\Entity\Paragraph $paragraph: The paragraph.

Return value

string[] The plugin settings.

Overrides ParagraphsBehaviorBase::settingsSummary

File

src/Plugin/paragraphs/Behavior/ParagraphsStylePlugin.php, line 291

Class

ParagraphsStylePlugin
Provides style selection plugin.

Namespace

Drupal\paragraphs_collection\Plugin\paragraphs\Behavior

Code

public function settingsSummary(Paragraph $paragraph) {
  $style_options = $this->yamlStyleDiscovery
    ->getStyleOptions();
  $summary = [];
  if ($styles = $paragraph
    ->getBehaviorSetting($this
    ->getPluginId(), 'styles')) {
    foreach ($styles as $group_id => $style) {

      // Check if the style set in the Paragraph is enabled in the collection.
      if (isset($style_options[$style]) && (!isset($this->configuration['groups'][$group_id]) || $style != $this->configuration['groups'][$group_id]['default'])) {
        $summary[] = [
          'label' => $this->yamlStyleDiscovery
            ->getGroupWidgetLabel($group_id),
          'value' => $style_options[$style],
        ];
      }
    }
  }
  return $summary;
}