Laravel-Backpack/PageManager

Ability to config the location of PageTemplates

promatik opened this issue · 2 comments

Suggestion

Does it make sense for developers to be able to configure the location of PageTemplates.php?
If possible I would like to be able to move PageTemplates.php inside a folder, just to keep the project organized.

There is the possibility to extend page_model_class and thereafter, manually relocate PageTemplates.php, but by adding an extra parameter to config maybe a page_template_class, it would be easier to just relocate PageTemplates.php.

If you agree with this, I can help with a PR!

Hi @promatik - I think that would be a "nice-to-have" feature and we could definitely include it, but I don't see how it would be technically possible. The PageTemplates class is now used in PageCrudController as a trait. So that whatever methods you put in PageTemplates, they would also be available in PageCrudController.

I don't know of any way to dinamically load and use a trait in another class, having just its FQN, other than using eval() or reflection hacks or other frowned-upon solutions. Generally I understand it's a bad idea to load traits after runtime.

If you do know of another solution, I am all ears - this would help in a bunch of other places too. But I doubt it's possible in a "proper" way that abides to some sort of good PHP practices.

Thanks, cheers!

@tabacitu you're right, I tried a few things but yeah, it seems to be impossible, at least for now.
I'll close the issue for now, and maybe some day php introduces a way to do this in a nice way 👍