You are here

public function ExistingRightsCheckConfig::checkUserHasExistingRights in Commerce License 8.2

Checks whether the user already has the rights this license grants.

This is called on a configured plugin.

Parameters

\Drupal\user\UserInterface $user: The user being checked.

Return value

\Drupal\commerce_license\ExistingRights\ExistingRightsResult A rights result object specifying the result and messages.

Overrides ExistingRightsFromConfigurationCheckingInterface::checkUserHasExistingRights

File

tests/modules/commerce_license_test/src/Plugin/Commerce/LicenseType/ExistingRightsCheckConfig.php, line 22

Class

ExistingRightsCheckConfig
Test license type which reports the user has existing rights.

Namespace

Drupal\commerce_license_test\Plugin\Commerce\LicenseType

Code

public function checkUserHasExistingRights(UserInterface $user) {

  // Mark that we've been called.
  \Drupal::state()
    ->set('commerce_license_test.called.checkUserHasExistingRights', TRUE);

  // The state tells us whether to say rights exist or not.
  return ExistingRightsResult::rightsExistIf(\Drupal::state()
    ->get('commerce_license_test.existing_rights_check_config'), $this
    ->t("You already have the rights."), $this
    ->t("The user already has the rights."));
}