You are here

public function SocialDrupalContext::iRestrictRealNameUsage in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::iRestrictRealNameUsage()
  2. 8.5 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::iRestrictRealNameUsage()
  3. 8.6 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::iRestrictRealNameUsage()
  4. 8.7 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::iRestrictRealNameUsage()
  5. 8.8 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::iRestrictRealNameUsage()
  6. 10.3.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::iRestrictRealNameUsage()
  7. 10.0.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::iRestrictRealNameUsage()
  8. 10.2.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::iRestrictRealNameUsage()

I restrict real name usage

@When /^(?:|I )(un)?restrict real name usage/

File

tests/behat/features/bootstrap/SocialDrupalContext.php, line 378

Class

SocialDrupalContext
Provides pre-built step definitions for interacting with Open Social.

Namespace

Drupal\social\Behat

Code

public function iRestrictRealNameUsage($restrict = TRUE) {
  if (!\Drupal::service('module_handler')
    ->moduleExists("social_profile_privacy")) {
    throw new \Exception("Could not restrict real name usage because the Social Profile Privacy module is disabled.");
  }

  // Convert our negative match to a boolean.
  if ($restrict === "un") {
    $restrict = FALSE;
  }

  // TODO: Remove debug.
  if ($restrict !== FALSE && $restrict !== TRUE) {
    throw new \Exception("Restrict has unknown value " . print_r($restrict, true));
  }
  \Drupal::configFactory()
    ->getEditable('social_profile_privacy.settings')
    ->set("limit_search_and_mention", $restrict)
    ->save();
}