Skip to content

Make the enabled() function required#53

Merged
bramr94 merged 4 commits into
DutchCodingCompany:mainfrom
thyseus:enabled-function
Jan 20, 2026
Merged

Make the enabled() function required#53
bramr94 merged 4 commits into
DutchCodingCompany:mainfrom
thyseus:enabled-function

Conversation

@thyseus

@thyseus thyseus commented Jan 16, 2026

Copy link
Copy Markdown

the default behavior of enabling the plugin everywhere is dangerous, one may accidentally push the code to production.

the default behavior of enabling the plugin everywhere
is dangerous, one may accidentally push the code to
production.
@thyseus

thyseus commented Jan 16, 2026

Copy link
Copy Markdown
Author

alternatively i thought about = false so the buttons would simply "disappear" instead of throwing an exception on existing installations ?

@bramr94

bramr94 commented Jan 16, 2026

Copy link
Copy Markdown
Collaborator

That sounds like a good solution @thyseus

@thyseus

thyseus commented Jan 16, 2026

Copy link
Copy Markdown
Author

So should i add the = false ? Downside is: having enabled() and then nothing happens, because, in fact, its disabled, is confusing. Both solutions have their downsides :)

@thyseus

thyseus commented Jan 18, 2026

Copy link
Copy Markdown
Author

Last idea: we can rename it to enabledWhen() and make the parameter required, then its obvious what the method does ?

Would be an even bigger breaking change then, though.

@bramr94

bramr94 commented Jan 19, 2026

Copy link
Copy Markdown
Collaborator

I think for now the best solution is:

    public function enabled(Closure | bool $value = false): static

When we have a new major version release, we can remove the default value.

@bramr94 bramr94 merged commit 7866282 into DutchCodingCompany:main Jan 20, 2026
16 checks passed
@bramr94 bramr94 mentioned this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants