class ProfileTypeMultipleAccessCheck in Profile 8
Checks whether the profile type allows multiple profiles per user.
Requirements key: '_profile_type_multiple'.
Hierarchy
- class \Drupal\profile\Access\ProfileTypeMultipleAccessCheck implements AccessInterface
Expanded class hierarchy of ProfileTypeMultipleAccessCheck
1 string reference to 'ProfileTypeMultipleAccessCheck'
1 service uses ProfileTypeMultipleAccessCheck
File
- src/
Access/ ProfileTypeMultipleAccessCheck.php, line 15
Namespace
Drupal\profile\AccessView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ProfileTypeMultipleAccessCheck:: |
public | function | Performs the access check. |