<?php
class ContactPage extends DefaultPage {
...
}
default model:
<?php
class DefaultPage extends Page {
...
}
and the models folder structure:
> models
- contact.php
- default.php
I figured the system works alphabetically, though I didn’t have issues doing this back in Kirby 2. Is this a bug? Is there a workaround besides arranging it alphabetically?
I’m no expert at this, but I believe PSR-4 expects the filename to have the same name as the loaded class name.
So, I think, if you expect PSR-4 to load \MO\models\DefaultPage, the filename should be site/models/DefaultPage.php, but that of course won’t work with Kirby which expects default.php.
That might be the cause. Don’t know if there’s a solution.
Maybe you could alias the DefaultPage class to “default” and then load MO\models\default instead.
site/models/default.php
namespace MO\models;
class DefaultPage extends Kirby\Cms\Page {
// default stuff here
}
class_alias('MO\models\DefaultPage', 'MO\models\default');
// I think you need to specify namespaces, no sure tho...