Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions::for(): new $default argument #6548

Merged
merged 4 commits into from
Jul 24, 2024

Conversation

distantnative
Copy link
Member

@distantnative distantnative commented Jul 21, 2024

Description

Summary of changes

  • Permissions::for() has a new $default parameter specifying what is returned when the permission category or action is not found
  • Implemented $default also for ModelPermissions::can() and ::cannot()

Reasoning

Currently, if one wants to check for a permission but by default wants to grant it, there is no easy way. Instead one has to go through ->toArray() which isn't ideal. Allowing to also use ->for() improves this.

Changelog

Enhancements

  • $permissions->for(), $modelpermissions->can() and $modelpermissions->cannot() accept a new $default parameter

Ready?

  • In-code documentation (wherever needed)
  • Unit tests for fixed bug/feature
  • Tests and CI checks all pass

For review team

  • Add changes & docs to release notes draft in Notion

@distantnative distantnative added the type: enhancement ✨ Suggests an enhancement; improves Kirby label Jul 21, 2024
@distantnative distantnative added this to the 4.4.0 milestone Jul 21, 2024
@distantnative distantnative self-assigned this Jul 21, 2024
@distantnative distantnative force-pushed the enhancement/permissions-for-default branch 2 times, most recently from fb885d9 to 4377baf Compare July 21, 2024 10:52
@distantnative distantnative force-pushed the enhancement/permissions-for-default branch from 4377baf to ee08069 Compare July 21, 2024 10:55
@distantnative distantnative marked this pull request as ready for review July 21, 2024 10:59
@distantnative distantnative requested a review from a team July 21, 2024 10:59
@bastianallgeier bastianallgeier merged commit 3ae9978 into develop-minor Jul 24, 2024
12 checks passed
@bastianallgeier bastianallgeier deleted the enhancement/permissions-for-default branch July 24, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement ✨ Suggests an enhancement; improves Kirby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants