You are here

public function Post::setVisibility in Open Social 8.5

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::setVisibility()
  2. 8.4 modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::setVisibility()
  3. 8.6 modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::setVisibility()
  4. 8.7 modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::setVisibility()
  5. 8.8 modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::setVisibility()
  6. 10.3.x modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::setVisibility()
  7. 10.0.x modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::setVisibility()
  8. 10.1.x modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::setVisibility()
  9. 10.2.x modules/social_features/social_post/src/Entity/Post.php \Drupal\social_post\Entity\Post::setVisibility()

File

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

Class

Post
Defines the Post entity.

Namespace

Drupal\social_post\Entity

Code

public function setVisibility($visibility) {
  if ($this
    ->hasField('field_visibility')) {
    switch ($visibility) {
      case 'community':
        $this
          ->set('field_visibility', 0);
        break;
      case 'public':
        $this
          ->set('field_visibility', 1);
        break;
      case "group":
        $this
          ->set('field_visibility', 3);
        break;
    }
  }
  return $this;
}