You are here

class ProfileTypeMultipleAccessCheck in Profile 8

Checks whether the profile type allows multiple profiles per user.

Requirements key: '_profile_type_multiple'.

Hierarchy

Expanded class hierarchy of ProfileTypeMultipleAccessCheck

1 string reference to 'ProfileTypeMultipleAccessCheck'
profile.services.yml in ./profile.services.yml
profile.services.yml
1 service uses ProfileTypeMultipleAccessCheck
access_check.profile_type_multiple in ./profile.services.yml
Drupal\profile\Access\ProfileTypeMultipleAccessCheck

File

src/Access/ProfileTypeMultipleAccessCheck.php, line 15

Namespace

Drupal\profile\Access
View source
class ProfileTypeMultipleAccessCheck implements AccessInterface {

  /**
   * Performs the access check.
   *
   * @param \Symfony\Component\Routing\Route $route
   *   The route to check against.
   * @param \Drupal\profile\Entity\ProfileTypeInterface $profile_type
   *   The profile type.
   *
   * @return bool|\Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(Route $route, ProfileTypeInterface $profile_type) {
    $requirement = $route
      ->getRequirement('_profile_type_multiple');
    $requirement = filter_var($requirement, FILTER_VALIDATE_BOOLEAN);
    if ($requirement) {
      $access_result = AccessResult::allowedIf($profile_type
        ->allowsMultiple());
    }
    else {
      $access_result = AccessResult::allowedIf(!$profile_type
        ->allowsMultiple());
    }
    return $access_result
      ->addCacheableDependency($profile_type);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ProfileTypeMultipleAccessCheck::access public function Performs the access check.