There might be some reason why this wouldn't be a good idea, but could there be an additional option when using $config->usePageClasses = true so that pages automatically get a custom Page class that extends DefaultPage without there needing to be a matching class file in /site/classes/?
So that if I have a page using template product_page it is automatically an instance of ProductPage even if I haven't create a ProductPage.php file?
If I have a template that doesn't need any special methods in a custom class file beyond what I've added to DefaultPage I typically don't create an empty class file in /site/classes/. That would be just one more thing to remember (although I guess it could be done with a hook), clutters up the /site/classes/ folder, and feels redundant.
But then if I want to take advantage of Page class hookable methods I either have to create the empty class file, or if I want the clean separation of separate hooks for different Page classes I have to use a mixture of different approaches depending on whether the class file exists or not.
// Page with class file
// I'd rather do this for all pages as the separation is cleaner than having a chain of logic inside a single hook
$wire->addHook('FooPage::saveReady', function($event) {
// ...
});
// Page without class file
$wire->addHook('Page::saveReady', function($event) {
$page = $event->object;
if($page->template == 'bar') {
// ...
}
});
It would be nice to have all pages handled in the same way without needing empty class files.
There might be some reason why this wouldn't be a good idea, but could there be an additional option when using
$config->usePageClasses = trueso that pages automatically get a custom Page class that extendsDefaultPagewithout there needing to be a matching class file in/site/classes/?So that if I have a page using template
product_pageit is automatically an instance ofProductPageeven if I haven't create aProductPage.phpfile?If I have a template that doesn't need any special methods in a custom class file beyond what I've added to
DefaultPageI typically don't create an empty class file in/site/classes/. That would be just one more thing to remember (although I guess it could be done with a hook), clutters up the/site/classes/folder, and feels redundant.But then if I want to take advantage of Page class hookable methods I either have to create the empty class file, or if I want the clean separation of separate hooks for different Page classes I have to use a mixture of different approaches depending on whether the class file exists or not.
It would be nice to have all pages handled in the same way without needing empty class files.