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

Add constants for page resource schema slots #203

Merged
merged 2 commits into from
Jan 7, 2025

Conversation

Voltra
Copy link
Collaborator

@Voltra Voltra commented Jan 3, 2025

To avoid hard-coding strings in resource classes, typos, and for better autocompletion and "future-proofing", this PR introduces a new class Z3d0X\FilamentFabricator\View\ResourceSchemaSlot similar to #193 for layout render hooks

This means that codebases can migrate resource classes from:

FilamentFabricator::getSchemaSlot('sidebar.after')

to

FilamentFabricator::getSchemaSlot(\Z3d0X\FilamentFabricator\View\ResourceSchemaSlot::SIDEBAR_AFTER)

or even

use Z3d0X\FilamentFabricator\View\ResourceSchemaSlot;

// [...]

FilamentFabricator::getSchemaSlot(ResourceSchemaSlot::SIDEBAR_AFTER)

Copy link

what-the-diff bot commented Jan 3, 2025

PR Summary

  • Modification in PageResource.php
    The PageResource.php file has been updated to reference constants from a new class called ResourceSchemaSlot rather than using direct string literals. This change enhances code robustness ensuring fewer errors due to potential string literals' misspellings.

  • Introduction of ResourceSchemaSlot.php
    A fresh file named ResourceSchemaSlot.php has been incorporated. It introduces constants for various schema slots like BLOCKS_BEFORE, BLOCKS_AFTER, SIDEBAR_BEFORE, and SIDEBAR_AFTER. This addition promotes code readability and maintainability by minimizing the use of raw strings.

@Voltra Voltra self-assigned this Jan 3, 2025
@Z3d0X
Copy link
Owner

Z3d0X commented Jan 7, 2025

I'm still kind of leaning towards this.
#94 (comment)

@Voltra
Copy link
Collaborator Author

Voltra commented Jan 7, 2025

They're both compatible :)

@Z3d0X Z3d0X merged commit 51c7b87 into Z3d0X:2.x Jan 7, 2025
7 checks passed
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