You are here

public static function LearningPathAccess::setVisibilityFields in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/LearningPathAccess.php \Drupal\opigno_learning_path\LearningPathAccess::setVisibilityFields()

Set visibility fields on Learning Path group save.

2 calls to LearningPathAccess::setVisibilityFields()
opigno_learning_path_group_presave in ./opigno_learning_path.module
Sets additional fields for group visibility.
TrainingAccessTest::testTrainingStart in tests/src/Functional/TrainingAccessTest.php
Tests which users can subscribe and start a training.

File

src/LearningPathAccess.php, line 41

Class

LearningPathAccess
Class LearningPathAccess.

Namespace

Drupal\opigno_learning_path

Code

public static function setVisibilityFields(Group &$group) {
  if ($visibility = $group->field_learning_path_visibility->value) {
    switch ($visibility) {
      case 'public':
        $group
          ->set('field_anonymous_visibility', 0);
        $group
          ->set('field_requires_validation', 0);
        break;
      case 'private':
        $group
          ->set('field_anonymous_visibility', 1);
        $group
          ->set('field_requires_validation', 1);
        break;
    }
  }
}