Problem/Motivation
I want to create a form where I can list the users that can masquerade as a specific target user. However, masquerade_target_user_access() only has a parameter for the target user, and it assumes that I want to check the current user's access. This means I would need to copy the code into a custom function to allow checking for a different user.
Steps to reproduce
masquerade_target_user_access() doesn't have a parameter for user to check access for.
Proposed resolution
It would be simple to add a parameter and have it default to the current user if no value is passed.
Before
function masquerade_target_user_access(UserInterface $target_account) {
$user = \Drupal::currentUser();
After
function masquerade_target_user_access(UserInterface $target_account, ?UserInterface $user = NULL) {
if ($user === NULL) {
$user = \Drupal::currentUser();
}
Remaining tasks
In addition, this function should probably be moved into the service class, so that services can be injected from the container.
User interface changes
API changes
Data model changes
Issue fork masquerade-3528686
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
solideogloria commentedComment #3
solideogloria commentedComment #4
solideogloria commentedComment #5
chhavi.sharma commentedComment #7
chhavi.sharma commentedComment #8
solideogloria commentedLooks great!