Problem/Motivation
AccessResult::neutral() allows setting a reason but AccessResult::allowedIf() and AccessResult::forbiddenIf() don't allow setting a reason on the neutral result.
I think this is confusing DX. If reasons on neutral results are valuable, we should always allow setting it.
Steps to reproduce
AccessResult::neutral('This is neutral because...');
// I can't explain why this would be neutral.
AccessResult::allowedIf();
Proposed resolution
We could add a $reason parameter to allowedIf().
And pass the reason to neutral() in forbiddenIf().
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3566611
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:
- 3566611-its-not-always
changes, plain diff MR !15084
Comments
Comment #4
prudloff commentedComment #5
smustgrave commentedDoes seem to be a good quality of life improvement for the developers.
CR reads fine to me.
Have no additional feedback to give.
Comment #6
godotislateCouple suggestions on the MR.
Comment #7
prudloff commentedI applied the suggestions.
I had to fix some tests to avoid type errors.
Comment #8
smustgrave commentedFeedback appears to be addressed.
Comment #12
godotislateCommitted and pushed 06b4b89 to main and to 11.x. Thanks!
Published the CR.