You are here

public function ParagraphsLanguagePlugin::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/ParagraphsLanguagePlugin.php, line 188

Class

ParagraphsLanguagePlugin
Provides a way to hide specific paragraphs depending on the current language.

Namespace

Drupal\paragraphs_collection\Plugin\paragraphs\Behavior

Code

public function settingsSummary(Paragraph $paragraph) {
  $summary = [];
  if ($visibility = $paragraph
    ->getBehaviorSetting($this
    ->getPluginId(), 'container')) {
    if ($visibility['visibility'] == 'hide' || $visibility['visibility'] == 'show') {
      if (isset($visibility['languages'])) {
        $language_names = [];
        foreach ($visibility['languages'] as $language) {
          $language_names[] = $this->languageManager
            ->getLanguageName($language);
        }
        $summary[] = [
          'label' => $visibility['visibility'] == 'hide' ? $this
            ->t('Hide for') : $this
            ->t('Show for'),
          'value' => \implode(', ', $language_names),
        ];
      }
    }
  }
  return $summary;
}