You are here

public function Post::getDefaultVisibilityByLabel in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::getDefaultVisibilityByLabel()
  2. 8.8 modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::getDefaultVisibilityByLabel()
  3. 10.0.x modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::getDefaultVisibilityByLabel()
  4. 10.1.x modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::getDefaultVisibilityByLabel()
  5. 10.2.x modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::getDefaultVisibilityByLabel()

Get default visibility option.

Parameters

string $label: The visibility label.

bool $reverse: For setting or getting data.

Return value

string Visibility label.

2 calls to Post::getDefaultVisibilityByLabel()
Post::getVisibility in modules/social_features/social_post/src/Entity/Post.php
Post::setVisibility in modules/social_features/social_post/src/Entity/Post.php

File

modules/social_features/social_post/src/Entity/Post.php, line 211

Class

Post
Defines the Post entity.

Namespace

Drupal\social_post\Entity

Code

public function getDefaultVisibilityByLabel($label, $reverse = FALSE) {
  $default_visibilities = [
    [
      'id' => 'community',
      'label' => 'Community',
    ],
    [
      'id' => 'public',
      'label' => 'Public',
    ],
    [
      'id' => 'group',
      'label' => 'Group members',
    ],
  ];
  if ($reverse) {
    foreach ($default_visibilities as $visibility) {
      if ($visibility['id'] == $label) {
        return $visibility['label'];
      }
    }
  }
  else {
    foreach ($default_visibilities as $visibility) {
      if ($visibility['label'] == $label) {
        return $visibility['id'];
      }
    }
  }
}