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

Allow Cells to be auto-located within */Cells directories #6601

Merged
merged 3 commits into from
Sep 30, 2022
Merged

Conversation

lonnieezell
Copy link
Member

@lonnieezell lonnieezell commented Sep 28, 2022

Currently, when calling a View Cell you must enter the fully qualified class name. This change uses the FileLocator Factories class to search for the class within */Cells directories, allowing a simpler naming in views and a more standardized location for them.

So now we could do:

<?= view_cell('Blog::recent', 'limit=5') ?>

instead of

<?= view_cell('App\Modules\Blog\Cells\Blog::recent', 'limit=5') ?>

and it could be found in app/Cells, App/Modules/Blog/Cells, or any other namespace's Cells folder.

@kenjis kenjis added 4.3 enhancement PRs that improve existing functionalities labels Sep 28, 2022
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative which would offer a slightly broader feature (maybe desirable?) would be to use Factories; this would allow View Cells to support the "modular unless overwritten by App" features characteristic of Models and Configs.

For example, if Shield published a LoginCell then a developer would only need to supply app/Cells/LoginCell.php that extended it in order to use the replacement.

Just a thought; I like the improved locator skills generally.

@lonnieezell
Copy link
Member Author

I had considered using Factories for this, but was thinking more about the caching uses and thinking it wouldn't be worth it for this. So I could go either way on this. I'm not sure the memory usage would be worth it here. Although the "modular unless overwritten by App" aspect makes it tempting.

I'll go ahead and try this with factories.

@MGatner
Copy link
Member

MGatner commented Sep 29, 2022

Looks good with Factories! I'm fine with either way, was just an idea.

Picked up a User Guide syntax warning:

Warning: undefined label: view-cells

@kenjis
Copy link
Member

kenjis commented Sep 29, 2022

I suggested the fixes for the docs.
The implementation seems good!

Co-authored-by: kenjis <kenji.uui@gmail.com>
@lonnieezell
Copy link
Member Author

@kenjis thanks for the docs updates. I've merged those. So I think we've covered everything.

Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@lonnieezell lonnieezell merged commit adcfde7 into 4.3 Sep 30, 2022
@lonnieezell lonnieezell deleted the locate-cell branch September 30, 2022 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.3 enhancement PRs that improve existing functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants