public static function MultipleRegistrationController::checkFieldAccess in Multiple Registration 8
Same name and namespace in other branches
- 8.2 src/Controller/MultipleRegistrationController.php \Drupal\multiple_registration\Controller\MultipleRegistrationController::checkFieldAccess()
- 3.x src/Controller/MultipleRegistrationController.php \Drupal\multiple_registration\Controller\MultipleRegistrationController::checkFieldAccess()
Check is field available for role.
Parameters
array $fieldRoles: Array with assigned roles for the fields.
Return value
bool Returns access result.
2 calls to MultipleRegistrationController::checkFieldAccess()
File
- src/
Controller/ MultipleRegistrationController.php, line 245
Class
- MultipleRegistrationController
- Class MultipleRegistrationController.
Namespace
Drupal\multiple_registration\ControllerCode
public static function checkFieldAccess(array $fieldRoles) {
$routeMatch = \Drupal::routeMatch();
$roles = [];
switch ($routeMatch
->getRouteName()) {
// Role page registration.
case 'multiple_registration.role_registration_page':
$roles = [
$routeMatch
->getParameter('rid'),
];
break;
// Default registration.
case 'user.register':
$roles = [
self::MULTIPLE_REGISTRATION_GENERAL_REGISTRATION_ID,
];
break;
// User edit page.
case 'entity.user.edit_form':
$roles = $routeMatch
->getParameter('user')
->getRoles();
if (!static::useRegistrationPage($roles)) {
// Fall back to 'General registered users' if user does not have any
// special role.
$roles = [
self::MULTIPLE_REGISTRATION_GENERAL_REGISTRATION_ID,
];
}
break;
}
$extractKeys = array_intersect($roles, $fieldRoles);
if (!empty($extractKeys)) {
return TRUE;
}
else {
return FALSE;
}
}