You are here

public function StyleDiscovery::getGroupWidgetLabel in Paragraphs Collection 8

Gets group label for a widget context.

Parameters

string $group_id: The group id.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup The translatable group label.

Overrides StyleDiscoveryInterface::getGroupWidgetLabel

File

src/StyleDiscovery.php, line 303

Class

StyleDiscovery
Provides common helper methods for style discovery. @todo Create documentation for style discovery https://www.drupal.org/node/2837995

Namespace

Drupal\paragraphs_collection

Code

public function getGroupWidgetLabel($group_id) {
  $groups = $this
    ->getStyleGroups();
  if (isset($groups[$group_id])) {

    // If the widget label is empty use the general label and add a "style
    // suffix".
    if ($widget_label = $groups[$group_id]['widget_label']) {
      return $widget_label;
    }
    else {
      return $this
        ->t('@group_label style', [
        '@group_label' => $this
          ->getGroupLabel($group_id),
      ]);
    }
  }
  return NULL;
}